Jump to content

How to Export to multiple spreadsheets in excel using php


harikr

Recommended Posts

Hi everyone,

 

I already have a code which exports the data to single worksheet in excel. But i also need to export the data in multiple worksheets within a single excel.Please anyone help me out.

 

This is how i am exporting to a single spreadsheet in excel.

 

header("Content-Type: application/vnd.ms-excel");

header("Content-Disposition: filename=ExcelExport.xls");

This isn't exporting anything to Excel, it's setting the http response headers to download an already existing Excel file.... and isn't setting all the headers at that.

 

How is the Excel file being created?

I have the data in the same file which i am exporting to excel with that headers. what i want is something like i want the data to be populated in two spreadsheets in excel.  i am not sure whether any headers needs to be set to pass the data to two spread sheets.

 

my code looks like this.

 

<?php

header("Content-Type: application/vnd.ms-excel");

header("Content-Disposition:attachment; filename=ExcelExport.xls");

                echo "<form name = 'details' action = '' method = 'post'>

                        <table  border='1' cellspacing='1' cellpadding='0' align='center'>

                        <tr  align='left' style='font-family: Arial;'>

                        <th>Comments</th>

                        </tr>

                        </table>

                        </form>";

?>

 

I have the data in the same file which i am exporting to excel with that headers[/Quote]This is NOT exporting to Excel.

 

This is writing HTML and pretending that's it's Excel to the browser.

 

You need to create a REAL Excel Workbook.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.