Cédric Girard
Cédric Girard

Reputation: 3410

Create a multi-tabs Excel file

My PHP script have to create a multi-tabs Excel file with a report in each tab, but those reports already exists as HTML pages, so I don't want to duplicate code and work. I know I can rename a HTML file to .xls, and Excel/OpenOffice Calc will open it as a spreadsheet, but I don't know how to have severals tabs.

I do not even know if it is possible.

I already know Biffwriter and others PHP libs to create Excel file, but I am looking for a smarter solution.

Thanks, Cédric

Upvotes: 1

Views: 3424

Answers (3)

SorinV
SorinV

Reputation: 624

If you don't mind serving excel 2007 files, you can do this:

  1. create an excel 2007 file
  2. create all the tabs you need
  3. save the file
  4. rename the file as .zip
  5. extract the contents of the zip file

Now you can use the file structure there to populate the file corresponding to each tab with the report you need. You may want to use them as templates, keep the same code and render different files depending on whether you generate the html report of the excel report.

In the end, zip up the entire directory structure and serve it with an xlsx extension.

Upvotes: 1

lakshmanaraj
lakshmanaraj

Reputation: 4175

Please check the URLS of a library and turorials from IBM and

from 999Tutorials

Upvotes: 0

Ólafur Waage
Ólafur Waage

Reputation: 69981

Pear Excel Spreadsheet Writer has a function to create new Worksheets if thats what you are looking for.

Upvotes: 1

Related Questions