PHP_XLSXWriter icon indicating copy to clipboard operation
PHP_XLSXWriter copied to clipboard

BUG: (oversight) writeSheetHeader function can't handle duplicate captions

Open AzzaAzza69 opened this issue 5 years ago • 2 comments

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');

AzzaAzza69 avatar Dec 05 '19 09:12 AzzaAzza69

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.

seattledeveloper avatar Dec 05 '19 22:12 seattledeveloper

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.

AzzaAzza69 avatar Dec 09 '19 01:12 AzzaAzza69

$writer->writeSheetHeader('Sheet1', $header1);
$writer->writeSheetRow('Sheet1', $row1 );
$writer->writeSheetHeader('Sheet1', $header2);
$writer->writeSheetRow('Sheet1', $row2);
``` this works now.

mk-j avatar May 31 '23 22:05 mk-j