PHP import and export of Excel file methods
1, PHP export Excel file
1: first recommends the uncoquettish PHPExcel, the official website:
2, Spreadsheet_Excel_Writer class
download address with pear: > > Iter
dependency on OLE, download address: http://pear.php.net/package/OLE
it needs to be noted that the exported Excel file format is older, and the modified save will be prompted to be converted into an updated format. But it can be formatted, very powerful.
3: uses Smarty to generate XML or HTML files that conform to the Excel specification
support format, a very perfect export solution. However, the essence of the XML file is, if it is used to import, it needs additional processing.
details to see the post of rardge Warrior: http://bbs.chinaunix.net/viewthread.php? Tid=745757
it is necessary to note that if the number of exported forms is uncertain, it is best to delete "ss:ExpandedColumnCount=" 5 "ss:ExpandedRowCount =" 21 "" in the template.
4, using the pack function to print out the analog Excel form of sentence symbols, this is closer to the Excel standard format, office2003 modified to save, and will not play a hint, recommend this method. The shortcoming is that there is no format.
5,
tab "t" by using a tabs, a row character, the user divides the columns in the same line, and the newline "TN" can open the next line.
6, using com
if your PHP can open the COM module, you can use it to export the Excel file
two, PHP import excel file
1. to read / > convert into text format, and then analyze the file again, There is no difference between the analysis of the text and the PHP.
advantages: cross platform, high efficiency, can read and write.
disadvantages: only.Csv files can be used directly. If.Xls binary files are often accepted, manual transformation is needed, and automation can not be done. A file has only one SHEET.
PHP has its own analytical.Csv function: fgetcsv
2. ODBC link data source
advantages: support multiple formats, CVs, xls, and so on. Support reading and writing, using standard SQL language, and SQLSERVER, MYSQL database almost exactly the same.
drawback: value supports Windows Server
3. PHP custom class
advantages: cross platform. Some classes support write operations. Support.Xls binary file
commonly used classes have phpExcelReader, PHPExcel. The latter supports reading and writing, but requires more than php5.2 versions.
phpExcelReader is specially used to read files. Returns an array containing all the contents of the table.