Replies: 1 comment 3 replies
-
You should be able to use the BeforeWriting event to set the sheet index to your choice |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I had a request from client to set default sheet when exporting multiple sheets.
Reviewing the code it was easy to set.
in maatwebsite/excel/src/Writer.php I saw that its hardcoded to 0 in write function:
$this->spreadsheet->setActiveSheetIndex(0), the idea is to add extra parameter $defaultSheetIndex=0 in write function and export function in Writer.php.
implemented asto this,
in order to complete it also needs to be added in: maatwebsite/excel/src/Exporter.php interface in download function:
public function download($export, string $fileName, string $writerType = null, array $headers = [],$defaultSheetIndex);
also in maatwebsite/excel/src/Excel.php in functions export and write functions:
In sheets() function i set selectedSheetIndex variable, and in my case I also implemented function in myExport class that generates the sheet this:
there might be another effiecent implemenatation as sheets() get called twice in my case, but it does the job:
Hope to see this upstream
Sami
Beta Was this translation helpful? Give feedback.
All reactions