tags:

views:

933

answers:

3

Hi,

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

+1  A: 

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

Ólafur Waage
No solution using a HTML file as source?
Cédric Girard
A: 

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

from 999Tutorials

lakshmanaraj
No solution using a HTML file as source? XML worksheets are not handled as standard XLS files.
Cédric Girard
+1  A: 

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.

SorinV
Good idea for the future, but our customers do not have Excel 2007.
Cédric Girard