aVadim483 / fast-excel-writer

Lightweight and very fast XLSX Excel Spreadsheet Writer in PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

AzzaAzza69 opened this issue · comments

$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?

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

Fixed. Thanks.