问题
I need an import tools for a web app. I've been looking around and found some, just not sure about their stability. I'm using the Zend Framework for part of the project and was hoping I could find an import tool there, since I already have the framework, but couldn't see one...am I looking in the wrong place?
I would like the web users to be able to import csv, excel files into a mysql database. I'd like the tool to allow the users to select the columns of the spreadsheet/csv to match up to the database columns if possible. For the exporting side I'm leaning to using jasper reports to export a dataset to csv,excel...is this a good/bad idea?
Are there some tools free or commercial tools that you have used and would recommend, to allow me to incorporate this feature into my website?
Thanks.
回答1:
For import:
Try MySql's built-in csv import: LOAD DATA INFILE
LOAD DATA INFILE 'yourdata.csv' INTO TABLE tbl_name
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n';
For export:
Try the jQuery plugin: table2csv. It converts an HTML table into a CSV file. Use the argument, delivery:'value', to return the csv as a string.
Here's an example implementation. I know it's in C#, but there's only a little code involved. It would be easy to port to PHP.
来源:https://stackoverflow.com/questions/2262343/import-tool-excel-csv