I'm using Maatwebsite/Laravel-Excel to export xlsx file.
How to set strikethrough for cell like image
I have read document but can't resolve.
My code (not work):
$sheet->cells("I5", function($cells) {
$cells->setFont(array(
// 'underline' => true
'strikethrough'=>true
));
});
Thank!
According to documentation, you can style your Cell or Stylesheet (https://laravel-excel.maatwebsite.nl/2.1/blade/styling.html) :
// Set font with ->setStyle()`
$sheet->setStyle(array(
'font' => array(
'name' => 'Calibri',
'size' => 12,
'bold' => true,
'strikethrough' => true,
)
));
It uses PhpOffice / Spreadsheet, so look the doc of this plugin : https://phpspreadsheet.readthedocs.io/en/develop/topics/recipes/
Related
i want to to implement cakepdf in my project and i want to use tcpdf as pdf engine. i know the recommendet engine was WkHtmlToPdf but i prefer the tcpdf engine. and i want to know how i can implement engine specific options for tcpdf.
i tried it over the the options array in the Configuration but nothing works. i also tried it over the viewBuilder->setOptions function but again nothing works. as example i need to disable the header and footer and i know it works with the setPrintHeader => false.
i tried it in the AppController with this
Configure::write('CakePdf', [
'engine' => 'CakePdf.Tcpdf',
'orientation' => 'portrait',
'download' => true,
'options' => [
'setPrintHeader' => false,
'setPrintFooter' => false
]
]);
and also with this
$this->viewBuilder()->setClassName('CakePdf.Pdf');
$this->viewBuilder()->setOptions([
'pdfConfig' => [
'orientation' => 'portrait',
'filename' => 'test_',
'setPrintHeader' => false,
'setPrintFooter' => false
]
]);
nothing of these works. the header and footer lines also print on the pdf. how i can disable this ?
I´m having a problem with phpword (https://phpword.readthedocs.io/en/latest/index.html)
I want to create a line where all the background is one color (100% width), but I can only make the background the size of the text.
$titleStyle=array('name' => 'Calibri','size' => 11, 'align' =>'center','marginTop' => 10,'bgColor' => 'd0cece');
// Create a new table style
$table_style = new \PhpOffice\PhpWord\Style\Table;
$table_style->setUnit(\PhpOffice\PhpWord\Style\Table::WIDTH_PERCENT);
$table_style->setWidth(100 * 50);
$table_style->setBgColor('d0cece');
// Set up our table.
$tableTitle = $section->addTable($table_style);
$tableTitle->addRow();
$tableTitle->addCell()->addText('Identificação pessoal',$titleStyle);
Someone can help me?
I'm not really familiar with PhpWord, but have you tried to set width of a cell to 100% of document?
$titleStyle = array(
'name' => 'Calibri',
'size' => 11,
'align' =>'center',
'marginTop' => 10,
'bgColor' => 'd0cece',
'width' => 11905.51181102
);
From what I see in the docs, cell width needs to be provided in twip units, which after conversion from 210mm is 11905.51181102 (A4 page width)
https://www.translatorscafe.com/unit-converter/en/typography/1-3/twip-centimeter/
I am using Kartik mpdf library to generate pdf. I am generating barcode in the body of the pdf which contains mcqs question generated through loop so pages are inserted randomly depending on the questions, So I need the page number to be set in my barcode on each page.
Kartik mpdf provides a method 'SetFooter' => ['{PAGENO}|'] which gives page number in footer but this {'PAGENO'} is not working in my html document... How would I get the page number inside my document.
PAGENO has nothing to do with kartik, is from mpdf. When you say is not working in your html, that's because that placeholder variable is going to be parsed with mpdf, so if you are not generating a pdf it wont take effect.
On the other hand, you can't show the page number in your html. There's no pages numbers on a html document, as it will depend in the page size and the font size of the browser, so it won't be possible to know "where you are" on the server side.
I hope you are using renderPartial method. Please find my code below.
$pdf = new Pdf([
'mode' => Pdf::MODE_UTF8, // leaner size using standard fonts
'destination' => Pdf::DEST_BROWSER,
'orientation' => Pdf::ORIENT_PORTRAIT,
'content' => $this->renderPartial('print', [
'model' => $model,
'quotations' => $modelQtn,
'pageNo' => ['{PAGENO} of {nb}'],
]),
'filename' => $model->po_no,
'cssFile' => [
'#vendor/../backend/assets/css/custom-style.css',
'#vendor/kartik-v/yii2-mpdf/src/assets/kv-mpdf-bootstrap.min.css',
],
// any css to be embedded if required
'cssInline' => '
.kv-heading-1 {
font-size:26px
}
.text-center {
font-family : Arial !important;
font-size:
}',
'options' => [
// any mpdf options you wish to set
'title' => 'Purchase Order'
],
'methods' => [
'SetTitle' => $model->po_no,
'SetSubject' => 'Mohammed Iqbal Khan',
'SetHeader' => [ 'Generated On: ' . date("F j, Y, g:i a")],
'SetFooter' => ['|Page {PAGENO} of {nb}|'],
'SetAuthor' => 'Mohammed Iqbal Khan',
'SetCreator' => 'Mohammed Iqbal Khan',
'SetKeywords' => 'Mohammed Iqbal Khan',
'SetWatermarkText' => 'DRAFT',
'SetWatermarkImage' => '',
]
]);
return $pdf->render();
Once you pass the page no method, then you can use the below code to show page no in your document while generating.
<?= $pageNo[0];?>
We have a website that is currently on an Ubuntu 16.04 server and we are working on moving to Amazon. The rest of the site (Written in PHP Yii 1.1) is working fine except for the piece that present our reports in PDF format.
The report is written to pdf with no real issue but images show as a red X After some debugging I came to the conclusion that the majority of the images are png images and that is why they do not show. The single jpg image on the report is showing.
How can I get this to work? The html version of the report (that uses different code) gets the image from the same place and that works just fine. I cannot really convert all images because they are generated dynamically.
I read somewhere that pdf does not support png images, REALLY?? Why did it render just fine on the current server?
I do not believe that is is going to help but here is some code used:
main.config:
'ePdf' => array(
'class' => 'ext.yii-pdf.EYiiPdf',
'params' => array(
'mpdf' => array(
'librarySourcePath' => 'application.vendors.mpdf.*',
'constants' => array(
'_MPDF_TEMP_PATH' => Yii::getPathOfAlias('application.runtime'),
),
'class'=>'mpdf', // the literal class filename to be loaded from the vendors folder
'defaultParams' => array( // More info: http://mpdf1.com/manual/index.php?tid=184
'mode' => '', // This parameter specifies the mode of the new document.
'format' => 'A4', // format A4, A5, ...
'default_font_size' => 0, // Sets the default document font size in points (pt)
'default_font' => '', // Sets the default font-family for the new document.
'mgl' => 15, // margin_left. Sets the page margins for the new document.
'mgr' => 15, // margin_right
'mgt' => 16, // margin_top
'mgb' => 16, // margin_bottom
'mgh' => 9, // margin_header
'mgf' => 9, // margin_footer
'orientation' => 'P', // landscape or portrait orientation
)
),
),
Controller:
$mPDF1 = Yii::app()->ePdf->mpdf('utf-8', 'A4');
$mPDF1->simpleTables = true;
$mPDF1->useSubstitutions = false;
$mPDF1->WriteHTML($this->renderPartial('pdfRXMapFile', array('model' => $model)));
I am trying to set background color of a call based on cell value, But i am getting error when i use the below code
function bgColor($cell,$color){
global $F;
$F->getStyle($cell)->applyFromArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'startcolor' => array('rgb' => $color),
'endcolor' => array('rgb' => $color)
//'color' => array('argb' => $color)
)
)
);
}
if i use rgb the following error occurs
Repaired Part: /xl/styles.xml part with XML error. (Styles) Load error. Line 2, column 934.
Removed Feature: Format from /xl/styles.xml part (Styles)
Removed Records: Style from /xl/styles.xml part (Styles)
if i use argb the first cell is filled with black color, while the argument passed to the color is yellow.
Ca anyone please tell me what i am doing wrong here