mk-j / PHP_XLSXWriter

Lightweight XLSX Excel Spreadsheet Writer in PHP
MIT License
1.84k stars 663 forks source link

How can I.. ? #319

Closed geeflaxx closed 1 year ago

geeflaxx commented 2 years ago

Hey, this framework is awesome!

How can I grow up the cell ? A2 is bigger than the cell

  $writer->writeSheetHeader('Sheet1', $header, $styles2, $col_options = ['widths'=>[50,20,30,40,50,60], 'suppress_row'=> 1] );
doesn't work

How can I add '%' ? ( nice to have but not important )

how can I add strings in a cell with a newliine ? ( \n doesn't work )

thank you very much!

grafik

askme-gpt commented 2 years ago

I can help you in question 2.

<?php
include_once("XlsWriter.class.php");

$header = [
    'created' => 'string',
    'product_id' => 'integer',
    'quantity' => '#,##0',
    'amount' => 'price',
    'description' => 'string',
    'tax' => '[$$-1009]#,##0.00;[RED]-[$$-1009]#,##0.00',
];
$data = [
    ['2015-12-01'."\n".'sfdsdfasdad111111', 873, 1, '44.00', 'misc', '=D2*0.05'],
    ['2015-01-12', 324, 2, '88.00', 'none', '=D3*0.05'],
];

$styles1 = ['font' => 'Arial', 'font-size' => 10, 'font-style' => 'bold','wrap_text'=>true, 'fill' => '#eee', 'halign' => 'center', 'border' => 'left,right,top,bottom', 'border-style' => 'medium'];
$writer = new XLSXWriter();
$writer->writeSheetHeader('Sheet1', $header);
foreach ($data as $row)
    $writer->writeSheetRow('Sheet1', $row, $styles1);
$writer->writeToFile('example2.xlsx');

'wrap_text'=>true matters,and also you need "\n"

my sheet are all dot border ,how can I make it to your style ? I hope you could help me,thx image

askme-gpt commented 2 years ago

image

please show me the code

mk-j commented 1 year ago

If this is still an issue, you can make a new ticket.