Re: [PHP] export data to a ms excel file using php
Hi, Could any one explain better. I need just the grid lines for the excel sheet. I already tried that table border=1 but it shows the linings only to the valued cells. But i need to show the grid as in MS Excel. I tried TEXT/XML but i get the following error --- The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh javascript:location.reload() button, or try again later. -- A string literal was expected, but no opening quote character was found. Error processing resource 'http://localhost/dbtoxl... table border=1tr td width=10025 /tdtd width=100 jana /tdtd width=100... --- thanks in advance On Thu, Oct 23, 2008 at 3:21 AM, Nitsan Bin-Nun [EMAIL PROTECTED] wrote: And what about users who use office version 2003 (which do NOT support .xml charts) You can google a bit, I'm pretty sure I have already encountered a class for this case at Manuel's site (phpclasses). Nitsan On Wed, Oct 22, 2008 at 9:00 PM, Ashley Sheridan [EMAIL PROTECTED] wrote: On Wed, 2008-10-22 at 11:20 -0700, Jim Lucas wrote: [EMAIL PROTECTED] wrote: Hi, I have tried your MS-Excel MIME type in PHP. But am facing a small problem. I can't get the grid lines as look like in normal Excel file. Am using windows XP, Internet explorer 6.0, MS Excel 2003 Thanks in advance.-- Jim Lucas wrote : abderrazzak nejeoui wrote: can you help me to export data to a ms excel file using php. i tried to export them to an html format and change the extension to .xls that's work but i have lost the formatting excel and the navigator doesn't interpret my code in the same why (celles are not in the same size) Ok, so with the examples of others here, here is the shortest example that I came up with that should get you going. ?php header(Content-Type: application/vnd.ms-excel); header(Expires: 0); header(Cache-Control: must-revalidate, post-check=0, pre-check=0); $x = $y = range(0, 12); echo 'table'; echo 'trtd /tdtd' . join('/tdtd', $x) . '/td/tr'; foreach ( $x AS $xx ) { echo trtd{$xx}/td; foreach ( $y AS $yy ) { echo td=sum(.(chr(ord('b')+$yy)).1*a.($xx+2).)/td; } echo /tr; } echo '/table'; ? This will output a 14x14 table. It will calculate the totals for each cell in the actual spreadsheet once excel loads it. If you have any questions, ask away. You could change this line echo 'table'; to this echo 'table border=1'; This will give you borders around your content at least. Example: http://www.cmsws.com/examples/php/testscripts/[EMAIL PROTECTED]/0001.php I would checkout phpexcel also -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare I think you really need to save the file as an XML file, with the text/xml mime-type. Then, save an Excel file in the M$ Office 2003 XML file-type (not the 2007 xlsx!) and look at the code it produces and try to mimic that output as closely as possible. All you're doing is creating an HTML table and hoping Excel knows what to do with it, which is a bit like creating an image, sending it to the browser with a PDF mime and hoping it will open up in Adobe Reader; just not gonna work that way! Your best bet by far though, is to use a pre-built Excel export class. Take a look at PEAR of PHPLib, as these both have classes that do what you need. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] export data to a ms excel file using php
[snip] Could any one explain better. I need just the grid lines for the excel sheet. I already tried that table border=1 but it shows the linings only to the valued cells. But i need to show the grid as in MS Excel. I tried TEXT/XML but i get the following error [/snip] http://evolt.org/node/26896 Part of the problem is that an empty table cell has no borders. To combat this you can test for a value and if it has none place a non-breaking space it (nbsp;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] export data to a ms excel file using php
Dear all, I found the solution for my problem. try this core... --- ?php #Setting MIME Type in header /*header(Content-Type: application/vnd.ms-excel); */ header(Content-Type: application/vnd.ms-excel); header(Expires: 0); /*header(Cache-Control: must-revalidate, post-check=0, pre-check=0); */ header(Cache-Control: must-revalidate); # Connecting to oracle server $dbh = oci_connect ('TESTDB', 'TESTDB', '//192.168.3.197/ORCL'); # Querry for fetching the column names $stmt = oci_parse ($dbh, Select COLUMN_NAME from user_tab_columns where table_name='EMPLOYEE'); # Execution of above statement oci_execute ($stmt); $cnt = 1; # Fetching column names and printing while ($result = oci_fetch_array($stmt)) { echo $result['COLUMN_NAME'] . ,; $cnt = $cnt +1; } # Make a new line to write the record sets in the next line echo \n; # Querry for fetching the recors sets $stmt = oci_parse ($dbh, 'select * from employee'); # Here we execute the statement: oci_execute ($stmt); $cnt = 1; /*echo 'table border=1';*/ # Then we fetch rows in a loop until we're done while ($result = oci_fetch_array($stmt)) { /*echo gopi, gopi, gopi, gopi, gopi, gopi, gopi \n;*/ /*echo Employee id . $result['EID'] . . $result['FNAME'] . . $result['LNAME'] . $result[SALARY] .br;*/ echo $result['EID'] . , . $result['FNAME'] . , . $result['LNAME'] . , . $result[SALARY] .\n; $cnt = $cnt +1; } /*echo '/table';*/ # last we close the database handle oci_close($dbh); ? --- On Thu, Oct 23, 2008 at 5:15 PM, Jay Blanchard [EMAIL PROTECTED]wrote: [snip] Could any one explain better. I need just the grid lines for the excel sheet. I already tried that table border=1 but it shows the linings only to the valued cells. But i need to show the grid as in MS Excel. I tried TEXT/XML but i get the following error [/snip] http://evolt.org/node/26896 Part of the problem is that an empty table cell has no borders. To combat this you can test for a value and if it has none place a non-breaking space it (nbsp;)
Re: [PHP] export data to a ms excel file using php
I'm not into MS Office, but isn't there some weird Office XML format since Office 2007? At MSDN I could find a nice description of the wannabe standard [1]. So if the new Excel can take XML it wouldn't be too difficult to export the data I guess. [1] http://msdn.microsoft.com/en-us/library/aa338205.aspx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] export data to a ms excel file using php
-Original Message- From: Yeti [mailto:[EMAIL PROTECTED] Sent: Thursday, October 23, 2008 9:36 AM To: gopi krishnan; PHP - General Subject: Re: [PHP] export data to a ms excel file using php I'm not into MS Office, but isn't there some weird Office XML format since Office 2007? At MSDN I could find a nice description of the wannabe standard [1]. So if the new Excel can take XML it wouldn't be too difficult to export the data I guess. [1] http://msdn.microsoft.com/en-us/library/aa338205.aspx Yes, the new extension for these files is *.xlsx . Also with Office 2007 are *.docx, *.pptx, etc. (See a pattern here?) When trying to load generated *.xls files in Office 2007, I'm greeted with a warning about Excel not being able to determine the type of the file. It still loads fine, and all the data and formatting are there... just barks at you every time you open it (or at least initially). I believe this is a known bug, but I don't have the time/patience to track it down in MSDN to link here. :) But to comment on your second point--yep, Excel 2007 will load XML (and even an associated XSD for determining formatting, validation, etc.). I haven't played with it too much, but I have successfully imported XML documents and used its best guess algorithm to build them into *.xls workbooks. No major hang-ups. (BTW, OpenOffice.org v3 has been released. http://www.openoffice.org - it supports the new Office 2007 formats, and could maybe be leveraged for conversion, etc.) HTH, Todd Boyd Web Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] export data to a ms excel file using php
gopi krishnan wrote: Dear all, I found the solution for my problem. try this core... --- ?php #Setting MIME Type in header /*header(Content-Type: application/vnd.ms-excel); */ header(Content-Type: application/vnd.ms-excel); header(Expires: 0); /*header(Cache-Control: must-revalidate, post-check=0, pre-check=0); */ header(Cache-Control: must-revalidate); # Connecting to oracle server $dbh = oci_connect ('TESTDB', 'TESTDB', '//192.168.3.197/ORCL'); # Querry for fetching the column names $stmt = oci_parse ($dbh, Select COLUMN_NAME from user_tab_columns where table_name='EMPLOYEE'); # Execution of above statement oci_execute ($stmt); $cnt = 1; # Fetching column names and printing while ($result = oci_fetch_array($stmt)) { echo $result['COLUMN_NAME'] . ,; $cnt = $cnt +1; } # Make a new line to write the record sets in the next line echo \n; # Querry for fetching the recors sets $stmt = oci_parse ($dbh, 'select * from employee'); # Here we execute the statement: oci_execute ($stmt); $cnt = 1; /*echo 'table border=1';*/ # Then we fetch rows in a loop until we're done while ($result = oci_fetch_array($stmt)) { /*echo gopi, gopi, gopi, gopi, gopi, gopi, gopi \n;*/ /*echo Employee id . $result['EID'] . . $result['FNAME'] . . $result['LNAME'] . $result[SALARY] .br;*/ echo $result['EID'] . , . $result['FNAME'] . , . $result['LNAME'] . , . $result[SALARY] .\n; $cnt = $cnt +1; } /*echo '/table';*/ # last we close the database handle oci_close($dbh); ? --- This would be correct. But, just to point out, you have a column count mismatch. You have 4 data fields that you are populating with 3 commas separating them. Yet in the column headers, you are outputting (i assume) 4 column headers with an extra comma at the end. I'm not sure what difference it would make your case. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] export data to a ms excel file using php
On Thu, 2008-10-23 at 13:05 +0530, gopi krishnan wrote: Hi, Could any one explain better. I need just the grid lines for the excel sheet. I already tried that table border=1 but it shows the linings only to the valued cells. But i need to show the grid as in MS Excel. I tried TEXT/XML but i get the following error --- The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh javascript:location.reload() button, or try again later. -- A string literal was expected, but no opening quote character was found. Error processing resource 'http://localhost/dbtoxl... table border=1tr td width=10025 /tdtd width=100 jana /tdtd width=100... --- thanks in advance On Thu, Oct 23, 2008 at 3:21 AM, Nitsan Bin-Nun [EMAIL PROTECTED] wrote: And what about users who use office version 2003 (which do NOT support .xml charts) You can google a bit, I'm pretty sure I have already encountered a class for this case at Manuel's site (phpclasses). Nitsan On Wed, Oct 22, 2008 at 9:00 PM, Ashley Sheridan [EMAIL PROTECTED] wrote: On Wed, 2008-10-22 at 11:20 -0700, Jim Lucas wrote: [EMAIL PROTECTED] wrote: Hi, I have tried your MS-Excel MIME type in PHP. But am facing a small problem. I can't get the grid lines as look like in normal Excel file. Am using windows XP, Internet explorer 6.0, MS Excel 2003 Thanks in advance.-- Jim Lucas wrote : abderrazzak nejeoui wrote: can you help me to export data to a ms excel file using php. i tried to export them to an html format and change the extension to .xls that's work but i have lost the formatting excel and the navigator doesn't interpret my code in the same why (celles are not in the same size) Ok, so with the examples of others here, here is the shortest example that I came up with that should get you going. ?php header(Content-Type: application/vnd.ms-excel); header(Expires: 0); header(Cache-Control: must-revalidate, post-check=0, pre-check=0); $x = $y = range(0, 12); echo 'table'; echo 'trtd /tdtd' . join('/tdtd', $x) . '/td/tr'; foreach ( $x AS $xx ) { echo trtd{$xx}/td; foreach ( $y AS $yy ) { echo td=sum(.(chr(ord('b')+$yy)).1*a.($xx+2).)/td; } echo /tr; } echo '/table'; ? This will output a 14x14 table. It will calculate the totals for each cell in the actual spreadsheet once excel loads it. If you have any questions, ask away. You could change this line echo 'table'; to this echo 'table border=1'; This will give you borders around your content at least. Example: http://www.cmsws.com/examples/php/testscripts/[EMAIL PROTECTED]/0001.php I would checkout phpexcel also -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare I think you really need to save the file as an XML file, with the text/xml mime-type. Then, save an Excel file in the M$ Office 2003 XML file-type (not the 2007 xlsx!) and look at the code it produces and try to mimic that output as closely as possible. All you're doing is creating an HTML table and hoping Excel knows what to do with it, which is a bit like creating an image, sending it to the browser with a PDF mime and hoping it will open up in Adobe Reader; just not gonna work that way! Your best bet by far though, is to use a pre-built Excel export class. Take a look at PEAR of PHPLib, as these both have classes that do what you need. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php the problem here is that you don't seem to understand the difference between xml, html and the binary excel format. Pick one, find out how it works and go with it. You seem to think that if you send down html to a browser, but give it a mime-type of application/excel it will suddenly become an excel document. not gonna happen, ever, period. my suggestion about using the text/xml header will only work _if you write the file as xml_ which you aren't. try using a class, or pay someone to do it if you can't. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] export data to a ms excel file using php
[EMAIL PROTECTED] wrote: Hi, I have tried your MS-Excel MIME type in PHP. But am facing a small problem. I can't get the grid lines as look like in normal Excel file. Am using windows XP, Internet explorer 6.0, MS Excel 2003 Thanks in advance.-- Jim Lucas wrote : abderrazzak nejeoui wrote: can you help me to export data to a ms excel file using php. i tried to export them to an html format and change the extension to .xls that's work but i have lost the formatting excel and the navigator doesn't interpret my code in the same why (celles are not in the same size) Ok, so with the examples of others here, here is the shortest example that I came up with that should get you going. ?php header(Content-Type: application/vnd.ms-excel); header(Expires: 0); header(Cache-Control: must-revalidate, post-check=0, pre-check=0); $x = $y = range(0, 12); echo 'table'; echo 'trtd /tdtd' . join('/tdtd', $x) . '/td/tr'; foreach ( $x AS $xx ) { echo trtd{$xx}/td; foreach ( $y AS $yy ) { echo td=sum(.(chr(ord('b')+$yy)).1*a.($xx+2).)/td; } echo /tr; } echo '/table'; ? This will output a 14x14 table. It will calculate the totals for each cell in the actual spreadsheet once excel loads it. If you have any questions, ask away. You could change this line echo 'table'; to this echo 'table border=1'; This will give you borders around your content at least. Example: http://www.cmsws.com/examples/php/testscripts/[EMAIL PROTECTED]/0001.php I would checkout phpexcel also -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] export data to a ms excel file using php
On Wed, 2008-10-22 at 11:20 -0700, Jim Lucas wrote: [EMAIL PROTECTED] wrote: Hi, I have tried your MS-Excel MIME type in PHP. But am facing a small problem. I can't get the grid lines as look like in normal Excel file. Am using windows XP, Internet explorer 6.0, MS Excel 2003 Thanks in advance.-- Jim Lucas wrote : abderrazzak nejeoui wrote: can you help me to export data to a ms excel file using php. i tried to export them to an html format and change the extension to .xls that's work but i have lost the formatting excel and the navigator doesn't interpret my code in the same why (celles are not in the same size) Ok, so with the examples of others here, here is the shortest example that I came up with that should get you going. ?php header(Content-Type: application/vnd.ms-excel); header(Expires: 0); header(Cache-Control: must-revalidate, post-check=0, pre-check=0); $x = $y = range(0, 12); echo 'table'; echo 'trtd /tdtd' . join('/tdtd', $x) . '/td/tr'; foreach ( $x AS $xx ) { echo trtd{$xx}/td; foreach ( $y AS $yy ) { echo td=sum(.(chr(ord('b')+$yy)).1*a.($xx+2).)/td; } echo /tr; } echo '/table'; ? This will output a 14x14 table. It will calculate the totals for each cell in the actual spreadsheet once excel loads it. If you have any questions, ask away. You could change this line echo 'table'; to this echo 'table border=1'; This will give you borders around your content at least. Example: http://www.cmsws.com/examples/php/testscripts/[EMAIL PROTECTED]/0001.php I would checkout phpexcel also -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare I think you really need to save the file as an XML file, with the text/xml mime-type. Then, save an Excel file in the M$ Office 2003 XML file-type (not the 2007 xlsx!) and look at the code it produces and try to mimic that output as closely as possible. All you're doing is creating an HTML table and hoping Excel knows what to do with it, which is a bit like creating an image, sending it to the browser with a PDF mime and hoping it will open up in Adobe Reader; just not gonna work that way! Your best bet by far though, is to use a pre-built Excel export class. Take a look at PEAR of PHPLib, as these both have classes that do what you need. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] export data to a ms excel file using php
And what about users who use office version 2003 (which do NOT support .xml charts) You can google a bit, I'm pretty sure I have already encountered a class for this case at Manuel's site (phpclasses). Nitsan On Wed, Oct 22, 2008 at 9:00 PM, Ashley Sheridan [EMAIL PROTECTED]wrote: On Wed, 2008-10-22 at 11:20 -0700, Jim Lucas wrote: [EMAIL PROTECTED] wrote: Hi, I have tried your MS-Excel MIME type in PHP. But am facing a small problem. I can't get the grid lines as look like in normal Excel file. Am using windows XP, Internet explorer 6.0, MS Excel 2003 Thanks in advance.-- Jim Lucas wrote : abderrazzak nejeoui wrote: can you help me to export data to a ms excel file using php. i tried to export them to an html format and change the extension to .xls that's work but i have lost the formatting excel and the navigator doesn't interpret my code in the same why (celles are not in the same size) Ok, so with the examples of others here, here is the shortest example that I came up with that should get you going. ?php header(Content-Type: application/vnd.ms-excel); header(Expires: 0); header(Cache-Control: must-revalidate, post-check=0, pre-check=0); $x = $y = range(0, 12); echo 'table'; echo 'trtd /tdtd' . join('/tdtd', $x) . '/td/tr'; foreach ( $x AS $xx ) { echo trtd{$xx}/td; foreach ( $y AS $yy ) { echo td=sum(.(chr(ord('b')+$yy)).1*a.($xx+2).)/td; } echo /tr; } echo '/table'; ? This will output a 14x14 table. It will calculate the totals for each cell in the actual spreadsheet once excel loads it. If you have any questions, ask away. You could change this line echo 'table'; to this echo 'table border=1'; This will give you borders around your content at least. Example: http://www.cmsws.com/examples/php/testscripts/[EMAIL PROTECTED]/0001.php I would checkout phpexcel also -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare I think you really need to save the file as an XML file, with the text/xml mime-type. Then, save an Excel file in the M$ Office 2003 XML file-type (not the 2007 xlsx!) and look at the code it produces and try to mimic that output as closely as possible. All you're doing is creating an HTML table and hoping Excel knows what to do with it, which is a bit like creating an image, sending it to the browser with a PDF mime and hoping it will open up in Adobe Reader; just not gonna work that way! Your best bet by far though, is to use a pre-built Excel export class. Take a look at PEAR of PHPLib, as these both have classes that do what you need. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] export data to a ms excel file using php
The easiest solution is to output CSV, and use the Content-type to force it to be eXcel. Excel will suck the CSV in just fine, with minimal hassle by the user. It also makes a file that is useful for many more applications, not just Excel. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] export data to a ms excel file using php
On Wed, 2008-10-22 at 22:04 +, [EMAIL PROTECTED] wrote: The easiest solution is to output CSV, and use the Content-type to force it to be eXcel. Excel will suck the CSV in just fine, with minimal hassle by the user. It also makes a file that is useful for many more applications, not just Excel. I don't think this is right for the situation, as you'll see if you re-read the original question. He wants to preserve things like column widths, and I know for a fact that Excel will not automatically expand all columns to best fit the data, and CSV is a pure data format, so will not do here. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] export data to a ms excel file using php
On Tue, December 18, 2007 3:05 am, abderrazzak nejeoui wrote: can you help me to export data to a ms excel file using php. i tried to export them to an html format and change the extension to .xls that's work but i have lost the formatting excel and the navigator doesn't interpret my code in the same why (celles are not in the same size) There is an Excel writer script in the PEAR site: http://pear.php.net/ Never tried it... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] export data to a ms excel file using php
can you help me to export data to a ms excel file using php. i tried to export them to an html format and change the extension to .xls that's work but i have lost the formatting Save the data from PHP in comma separated value (CSV) format. Edward -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] export data to a ms excel file using php
On Dec 18, 2007, at 4:05 AM, abderrazzak nejeoui wrote: can you help me to export data to a ms excel file using php. i tried to export them to an html format and change the extension to .xls that's work but i have lost the formatting excel and the navigator doesn't interpret my code in the same why (celles are not in the same size) Hi Abderrazzak, This is a script that I use to export to excel, and it works quite well after pulling the info from a Database. If you find any issues with it, let me know so I can try and fix it! But I haven't had any complaints about it yet. ?PHP $sortOrder = $_SESSION['order']; $search = $_SESSION['search']; $select = SELECT * FROM .$table. WHERE FName like '%.$search.%' or LName like '%.$search.%' or Add1 like '%.$search.%' or Add2 like '%.$search.%' or City like '%.$search.%' or State like '%. $search.%' or Zip like '%.$search.%' or XCode like '%.$search.%' order by .$sortOrder.; $export = mysql_query($select); $fields = mysql_num_fields($export); for ($i = 0; $i $fields; $i++) { $header .= mysql_field_name($export, $i) . \t; } while($row = mysql_fetch_row($export)) { $line = ''; foreach($row as $value) { if ((!isset($value)) or ($value == )) { $value = \t; } else { $value = str_replace('', '', $value); $value = '' . $value . '' . \t; } $line .= $value; } $data .= trim($line). \n; } $data = str_replace(\r, , $data); if ($data ==) { $data =\n(0) Records Found!\n; } header(Content-type: application/x-msdownload); header(Content-Disposition: attachment; filename=Export.xls); header(Pragma: no-cache); header(Expires: 0); print $header\n$data; ? -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] export data to a ms excel file using php
[snip] can you help me to export data to a ms excel file using php. i tried to export them to an html format and change the extension to .xls that's work but i have lost the formatting excel and the navigator doesn't interpret my code in the same why (celles are not in the same size) [/snip] Here is an old article that may help; http://evolt.org/node/26896 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] export data to a ms excel file using php
abderrazzak nejeoui wrote: can you help me to export data to a ms excel file using php. i tried to export them to an html format and change the extension to .xls that's work but i have lost the formatting excel and the navigator doesn't interpret my code in the same why (celles are not in the same size) Ok, so with the examples of others here, here is the shortest example that I came up with that should get you going. ?php header(Content-Type: application/vnd.ms-excel); header(Expires: 0); header(Cache-Control: must-revalidate, post-check=0, pre-check=0); $x = $y = range(0, 12); echo 'table'; echo 'trtd /tdtd' . join('/tdtd', $x) . '/td/tr'; foreach ( $x AS $xx ) { echo trtd{$xx}/td; foreach ( $y AS $yy ) { echo td=sum(.(chr(ord('b')+$yy)).1*a.($xx+2).)/td; } echo /tr; } echo '/table'; ? This will output a 14x14 table. It will calculate the totals for each cell in the actual spreadsheet once excel loads it. If you have any questions, ask away. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] export data to a ms excel file using php
Jim Lucas wrote: abderrazzak nejeoui wrote: can you help me to export data to a ms excel file using php. i tried to export them to an html format and change the extension to .xls that's work but i have lost the formatting excel and the navigator doesn't interpret my code in the same why (celles are not in the same size) Ok, so with the examples of others here, here is the shortest example that I came up with that should get you going. ?php header(Content-Type: application/vnd.ms-excel); header(Expires: 0); header(Cache-Control: must-revalidate, post-check=0, pre-check=0); $x = $y = range(0, 12); echo 'table'; echo 'trtd /tdtd' . join('/tdtd', $x) . '/td/tr'; foreach ( $x AS $xx ) { echo trtd{$xx}/td; foreach ( $y AS $yy ) { echo td=sum(.(chr(ord('b')+$yy)).1*a.($xx+2).)/td; } echo /tr; } echo '/table'; ? This will output a 14x14 table. It will calculate the totals for each cell in the actual spreadsheet once excel loads it. If you have any questions, ask away. Note: as mentioned in one of the articles, you have to change the script name to .xls and have PHP parse the .xls file, otherwise IE will not render correctly. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] export data to a ms excel file using php
abderrazzak nejeoui wrote: can you help me to export data to a ms excel file using php. i tried to export them to an html format and change the extension to .xls that's work but i have lost the formatting excel and the navigator doesn't interpret my code in the same why (celles are not in the same size) http://pear.php.net/package/Spreadsheet_Excel_Writer might work well. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php