Skip to content

Conversation

@mawi12345
Copy link

Found you delayed the \fwrite($sheetFilePointer, '<sheetData>'); in WorksheetManager. But therefore invalid sheets will be generated if you simply call $writer->addNewSheetAndMakeItCurrent() without adding data to the worksheet.

in my opinion startSheet should look like this

public function startSheet(Worksheet $worksheet)
{
  ...
  \fwrite($sheetFilePointer, self::SHEET_XML_FILE_HEADER);
  \fwrite($sheetFilePointer, $this->getXMLFragmentForDefaultCellSizing());
  \fwrite($sheetFilePointer, $this->getXMLFragmentForColumnWidths());
  \fwrite($sheetFilePointer, '<sheetData>');

But then there is no time to call $writer->setDefaultColumnWidth or $writer->setDefaultRowHeight before the first sheet is created (by WriterMultiSheetsAbstract->openWriter()).

Therefore i have refactored setDefaultColumnWidth and setDefaultRowHeight to use the OptionsManager like writer->setTempFolder. I believe setting default values before the writer is opened is the easier way.

@mawi12345
Copy link
Author

Back to your solution!

Can not get this to work without delaying the the <sheetData>.
I have fixed the main problem by moving the started flag from WorksheetManager to the Worksheet.

Sadly the is now way to configure the the first worksheet that is created by openWriter.

@aphofstede
Copy link
Owner

Thanks! This seems to work well. I will merge this, let's see if we can get it merged into the main project finally.

@aphofstede aphofstede merged commit d065f95 into aphofstede:custom-column-widths May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants