feat: add sheet view support to XLSX writer

This makes it possible to freeze rows and columns, in addition to providing
other sheet view settings like zoom options.
This commit is contained in:
K J Kooistra committed 2020-05-15 14:23:41 +02:00
1 parent ab973cab34
commit b54e217799
6 files changed
+394 -2

No files matched your search

@@ -131,8 +131,6 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
$worksheetFilePath = $this->getWorksheetFilePath($sheet);
$worksheet = $this->entityFactory->createWorksheet($worksheetFilePath, $sheet);
$this->worksheetManager->startSheet($worksheet);
$worksheets[] = $worksheet;
$this->workbook->setWorksheets($worksheets);
@@ -223,8 +221,15 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
if ($hasReachedMaxRows) {
// ... continue writing in a new sheet if option set
if ($this->optionsManager->getOption(Options::SHOULD_CREATE_NEW_SHEETS_AUTOMATICALLY)) {
$previousSheet = $currentWorksheet->getExternalSheet();
$currentWorksheet = $this->addNewSheetAndMakeItCurrent();
// Use the same sheet view if set
$sheet = $currentWorksheet->getExternalSheet();
if ($previousSheet->hasSheetView()) {
$sheet->setSheetView($previousSheet->getSheetView());
}
$this->addRowToWorksheet($currentWorksheet, $row);
} else {
// otherwise, do nothing as the data won't be written anyways