How to save excel data to database in php

爱喝马黛茶的安东尼
Release: 2023-02-25 09:52:01
Original
4215 people have browsed it

How to save excel data to database in php

1. Use PHP

Excel Parser Pro software, but this software is a paid software;

2. You can save EXCEL tables in CSV format , and then import through phpmyadmin or SQLyog. The SQLyog import method is:

·Save the EXCEL table as CSV format;

·Open SQLyog , right-click the table to be imported, click "Import" - "Import using Load local CSV data";

·In the pop-up dialog box, click "Change..", Select "Fill in excel-friendly values" and click OK;

·Select the CSV file path to be imported in "Import from file" and click "Import" to import the data into the table Up;

Related recommendations: "php introductory tutorial"

Third, a relatively stupid manual method is to use excel to generate sql statements first, and then go to mysql Run, this method is suitable for importing excel tables into various sql databases:

· Assume that your table has three columns of data, A, B, and C, and you want to import them into your database. Table tablename, the corresponding fields are col1, col2, col3.

·Add a column to your table and use excel formulas to automatically generate sql statements. The specific method is as follows:

(1) Add a column (assuming it is column D )

(2) Enter the formula in column D of the first row, which is D1:

=CONCATENATE("insert into tablename (col1,col2,col3) values ​​(",A1, ",",B1,",",C1,");")

(3) At this time, D1 has generated the following sql statement:

insert into table (col1,col2 ,col3) values ​​('a','11','33');

(4) Copy the formula of D1 to column D of all rows (that is, use the mouse to click and hold the lower right corner of cell D1 Keep dragging it down)

(5) At this time, all sql statements have been generated in column D

(6) Copy column D to a plain text file, assuming it is sql. txt

·Just put sql.txt into the database and run it. You can import it using the command line or run it using phpadmin.

The above is the detailed content of How to save excel data to database in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!