CSV files store table data in plain text, so we can easily read and write CSV data through PHP arrays, here, let's take a look at the common operations of PHP to process CSV table files: to edit an online Excel table, the parsing of the Excel xls file format is a problem, after all, this is the private patent format of Microsoft Office.
To do this, use the common csv (Comma Separated Value, Comma-Separated Value) format.
Various office software can recognize csv tables, which are actually tables separated by specific delimiters (such as commas.
For PHP, fgetcsv reads the csv table and returns an array,
Then foreach outputs
CSV table rules:
1. separate the content of cells in each row with commas.
2. if the content of a cell contains a comma, the content of the cell will be enclosed in quotation marks.
3. if the content of a cell contains quotation marks:
(1) the quotation marks are not at the beginning or end. the content of this cell is not enclosed in quotation marks.
(2) when the quotation marks are at the beginning or end, the content of the cell will be enclosed in quotation marks, and the original quotation marks at the beginning and end will be escaped.
Read/write CSV
Save as an independent file
Download. php:
Download csv files
Test. php:
Automatically save the csv file to the specified location
For more information about common PHP operations for processing CSV table files, see The PHP Chinese website!
In this step, several lines of code can be implemented, which is very simple.The workload mainly lies in the browser front-end. we recommend that you use jQuery to perform DOM and AJAX operations,To achieve fine-grained double-click cell editing like phpMyAdmin, it is not difficult to submit AJAX,Or $ ("form"). serialize () once the entire table is written, and AJAX can also be submitted.