We think you might be interested in this job:
Creating multi-worksheet Excel files with Simple Excel | C.S. Rhymes C.S. Rhymes HomeBooksNigel's Intranet AdventureHow NOT to make a WebsiteHow NOT to use a SmartphoneMy WorkThemesPackagesSitesDemosStoriesSponsorsAboutBlogSponsorCreating multi-worksheet Excel files with Simple ExcelPublished: Oct 13, 2021 by C.S. RhymesRecently I had to create a large data export for a project. I like using Spatie’s Simple Excel package to do this as it is very simple to use and works well when exporting large amounts of data to a CSV or Excel file with the ability to stream a download to the browser.
Luckily, this package allows you to do this too.The writer objectThe Simple Excel package uses the box/spout package under the hood.
The docs show we can see how to get the current sheet, set a name for the current sheet and how to create a new sheet.Naming a worksheetTo name a worksheet we can use getCurrentSheet() to get the current sheet with the writer and then use setName() to set the name.$writer=SimpleExcelWriter::streamDownload('your-export.xlsx')->getWriter()$nameSheet=$writer->getCurrentSheet();$nameSheet->setName('Names');Creating a new worksheetTo create a new sheet we can use addNewSheetAndMakeItCurrent() and we can then use setName() once more to set the name of this new sheet.$addressSheet=$writer->addNewSheetAndMakeItCurrent();$addressSheet->setName('Addresses');Bringing it all togetherNow we know how to do the individual tasks we can bring it all together.