1

I have successfully generated on the fly an excel document having multiple worksheets with index on first sheet using PHP Spreadsheet_Excel_Writer_Worksheet.

But I am unable to print html data in multiple worksheets.

I am using following link of code.

 <?php 

 $html = <html xmlns:o="urn:schemas-microsoft-com:office:office"
            xmlns:w="urn:schemas-microsoft-com:office:excel"
            xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><div align="center">Hello</div></body></html>



   $worksheet->write(
            0,
            0,
            $html,
            $formatData);      ?>

When tried above code, it's chunk out the html data and print it as html code not parsing it.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • I'd suggest that you read the documentation for SEW; but you should populate the individual cells with raw data values, not with blocks of HTML markup – Mark Baker Mar 31 '14 at 07:03
  • I have only html document, i want to print it as it is. I have seen some document having no rows and borders and html document with images are printed over it. – user3480000 Mar 31 '14 at 07:05
  • In that case it's going to be very hard to achieve anything; but if all you have is a few images, then why do you need to create an xls file? though I don't see any images in your sample markup, just a single div with "Hello" in it – Mark Baker Mar 31 '14 at 07:09
  • There is no images, i have html tables in the database. – user3480000 Mar 31 '14 at 07:10
  • If you're extracting data from a database, then it should be in a structure that can be written to spreadsheet cells; but do it directly from the database data, not from HTML markup – Mark Baker Mar 31 '14 at 07:11
  • i have html table in the database like
    – user3480000 Mar 31 '14 at 07:13
  • How are you creating that HTML table? I'd assume iterating over the database query resultset rows, and writing that data with markup wrapped around it.... you need to do something similar when you build the excel file – Mark Baker Mar 31 '14 at 07:14
  • can i print html table to the excel or not? – user3480000 Mar 31 '14 at 07:21
  • Not with SEW you can't; even with my own PHPExcel library, you'd need to save the HTML to a file temporarily first, then load frm the HTML file and save to Excel – Mark Baker Mar 31 '14 at 07:26
  • Ok, Another question can i create multiple excel into a single excel with clickable index on one worksheet and other miltiple excel as seperated worksheets of that excel? – user3480000 Mar 31 '14 at 08:03
  • It's possible, yes (at least PHPExcel can); though I'm not certain that SEW supports internal links – Mark Baker Mar 31 '14 at 08:14
  • ok, how would i do it with PHPExcel? – user3480000 Mar 31 '14 at 09:02
  • As answered [here](http://stackoverflow.com/questions/16801732/combine-two-or-more-xls-files-as-worksheets-phpexcel/22419724#22419724) but using the HTML Reader instead of the Excel5 Reader – Mark Baker Mar 31 '14 at 09:21

0 Answers0