mk-j / PHP_XLSXWriter

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

Set header height: solution #292

Closed NitemareReal closed 1 year ago

NitemareReal commented 3 years ago

Hello, this library is very good but have some important lacks, very, very, very easy to implement. First lack is that I can't find any documentation about this library, just some examples, too simple and with lots of undocumented options (I had to do a lot of reverse ingeneering to find out how to use some options).

I found too that you can't give a row height for header, but solution is very very easy, you have to modify a little code to get that feature.

Locate "writeSheetHeader" function and after:

if (!$suppress_row)
{
    $header_row = array_keys($header_types);

replace:

$sheet->file_writer->write('<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="' . (1) . '">');

with:

$ht = isset($col_options['height']) ? floatval($col_options['height']) : 12.1;
$customHt = isset($col_options['height']) ? true : false;
$sheet->file_writer->write('<row collapsed="false" customFormat="false" customHeight="'.($customHt).'" hidden="false" ht="'.($ht).'" outlineLevel="0" r="' . (1) . '">');

That's all!! so simple!! you can set header height.

I have found too much lacks that are too simple to implement... it's unbelievable

uhlyarikp commented 3 years ago

Great, thx!

NitemareReal commented 3 years ago

Hello, to increase compatibility (Excel 2007), change:

$customHt = isset($col_options['height']) ? true : false;

with:

$customHt = isset($col_options['height']) ? "true" : "false";