View Full Version : Export HTML TABLE to EXCEL
Ratto84
05-10-2011, 11:32 AM
Hello, I've to export the records of an HTML table taken form joined MySQL tables to an excel file. How can I?
Thanks for your help
Ratto84
Beverleyh
05-10-2011, 01:58 PM
HTML tables normally copy and paste from a web page very well into an Excel spreadsheet (highlight and copy the table area of the web page and paste into Excel).
Is that what you mean or do you have direct access to the server that houses the website and its MySQL / phpMyAdmin and want to run some sort of query in the backend to export and merge directly to Excel?
Ratto84
05-10-2011, 02:43 PM
The first solution is great and new for me, thanks, but i meant the second way:
I've to export in excel a table full by record taken from various tables. But I can't do it by PhpAdmin, because I need a button clickable by every users. I'm italian so, I hope my english to be understandable. :D:D:D
Thanks
Ratto84
Beverleyh
05-10-2011, 03:51 PM
The 2nd option wouldn't work publicly (you didn't say that it was for the front-end of a website in your 1st post and I thought you were possibly asking how to run queries).
I not 100% sure but I think you'd need either something that outputs your web page table to a csv file or for you to prepare and provide the spreadsheet as a zipped download via a hyperlink.
There are ASP scripts out there that you can incorporate into your web page that output the HTML as a csv file but I haven't tried any so I cannot make any recommendations (sorry)
I think the main issues here are how often the data is updated and also your assumptions of what software your visitors have installed on their computers. If this is a public website (rather than an internal company system) you cannot guarantee that your visitors have Excel installed so providing a file in potentially 'wrong' format is confusing and frustrating. I also believe that security won't allow web based scripts to invoke an instance of Excel directly.
Assuming that the table data does not change too frequently though, I guess that it will be easiest for your visitors if you prepare and provide a zipped spreadsheet file in .xls format (to ensure backwards compatibility with older versions of MS Office), and a link to download Open Office if they need it.
Some of the other guys on the forum may be able to make other suggestions but I guess they'd need more info about your server setup and the type of data that you're wanting to offer for download as there may be tools already out there do a better job of providing/displaying/managing data that you want to make available.
midhul
05-11-2011, 07:44 AM
If you want to do that directly through script, you must somehow be able to create a bridge between the data in PHP and in Excel.
For that, you can use PHP libraries which allow conversion to Excel data, through XML support.
Try this: http://code.google.com/p/php-excel/
Also, you could do the same yourself by exploiting Excel's XML support. (Could get little complicated), like this: http://www.ibm.com/developerworks/opensource/library/os-phpexcel/index.html
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.