1,105,594 Community Members

Export Specific Content to Excel

Member Avatar
MackAttack30
Newbie Poster
4 posts since Jul 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi community,

I have a PHP page with a table in it that I want to export to Excel. I have seen multiple ways to export an entire PHP page to excel, but I only want to export the table within my page. Is there anyway to specify what content I would want to export to Excel using HTML or PHP or anything? I have seen this example:

$filename ="excelreport.xls";
$contents = "testdata1 \t testdata2 \t testdata3 \t \n";
header('Content-type: application/ms-excel');
header('Content-Disposition: attachment; filename='.$filename);
echo $contents;

but I have more than that on my page and with this method, it just downloads the whole page into excel.

Member Avatar
chrishea
Posting Virtuoso
1,525 posts since Sep 2008
Reputation Points: 182 [?]
Q&As Helped to Solve: 256 [?]
Skill Endorsements: 6 [?]
 
0
 

You should build a second version of the page with just the info to be exported and create the excel file from that.

Member Avatar
MackAttack30
Newbie Poster
4 posts since Jul 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

That's what i was trying to avoid but that's what i'll stick with until i can find something better. Thanks.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article