PHP_XLSXWriter
PHP_XLSXWriter copied to clipboard
BUG: (oversight) writeSheetHeader function can't handle duplicate captions
As "headings" are cells just like data - they should be able to contain duplicated text!
eg. $aCols=[]; $aCols['column']='@'; $aCols['column']='@'; // durh ; obviously $aCols['column']='@'; // durh ; obviously $aData=['data','data','data']; $o=new XLSXWriter(); $o->writeSheetHeader('sheet', $aCols); $o->writeSheetRow('sheet', $aData); $o->writeToFile('../public/test.xlsx');
Maybe a new function that uses the array without keys, eg. $aCols=[]; $aCols[]=['title'=>'column', 'format'=>'@']; $aCols[]=['title'=>'column', 'format'=>'@']; $aCols[]=['title'=>'column', 'format'=>'@']; $aData=['data','data','data']; $o=new XLSXWriter(); $o->writeSheetHeadings('sheet', $aCols); $o->writeSheetRow('sheet', $aData); $o->writeToFile('../public/test.xlsx');
FYI, you might also look at Pull Request #250 which also discusses this issue. I like your solution as an array without keys ... and the current function could auto-detect which format of the array is being sent in, for complete backwards compatibility.
I see a future problem in that any more options are going to require more parameters...whereas extra keys can be added to the array as the functionality increases... It is already harder to follow with the column widths defined as a completely separate array to the header captions & types.
$writer->writeSheetHeader('Sheet1', $header1);
$writer->writeSheetRow('Sheet1', $row1 );
$writer->writeSheetHeader('Sheet1', $header2);
$writer->writeSheetRow('Sheet1', $row2);
``` this works now.