aVadim483 / fast-excel-writer

Lightweight and very fast XLSX Excel Spreadsheet Writer in PHP
MIT License
142 stars 26 forks source link

applyRowHeight doesnt seem to work if row contains just an image? #35

Closed AzzaAzza69 closed 9 months ago

AzzaAzza69 commented 9 months ago
$sFilename='sample-image.png';
$sCell='A1';
$this->oWriterSheet->addImage($sCell, $sFilename);
// set row height to that of image
$aImages=$this->oWriterSheet->getImages();
$aImages=end($a);
$this->oWriterSheet->applyRowHeight($aImages['height'])->nextRow();

$this->oWriterSheet->writeHeader(['COL1','COL2','COL3')->applyFontStyleBold()->applyBgColor('#E0E0E0');

Without the ->nextRow(), the graphic AND the header row take up row #0. I have also tried $this->oWriterSheet->setRowHeight(1, $aImages['height']) instead of the applyRowHeight() but it still doesn't change the height.

The above example without the call to nextRow() will include the graphic but it will overhang the COL1, COL2 and COL3 row as the first row is also the same height as the second one.

Am I doing something wrong?

aVadim483 commented 9 months ago

I've fixed it in v.4.7 But the applyRowHeight() function is better used after changing the value in a cell or row. The addImage() function links the image, but does not change the cell value

Therefore, in your case, instead of

$this->oWriterSheet->applyRowHeight($aImages['height'])->nextRow();

it is better to use this code

$this->oWriterSheet->setRowHeight($sCell, $aImages['height'])->nextRow();
AzzaAzza69 commented 9 months ago

Fixed. Thanks.