我可以从excel生成mysql查询吗?

时间:2017-08-07 11:24:38

标签: php mysql excel dynamic export

我的excel文件中有一个表数据,

如何从excel数据生成mysql插入查询?

有没有解决办法将数据从excel导入mysql?

1 个答案:

答案 0 :(得分:1)

是的,您可以使用PHP从excel生成mysql查询。

error_reporting(E_ALL ^ E_NOTICE);
require_once 'query_generator.php';
$data = new Spreadsheet_Excel_Reader("example.xls");

输出: 的

INSERT INTO table_name VALUES ( '101', 'Narendra Modi', 'Cabinet Ministers', 'Personnel, Public Grievances and Pensions, Department of Atomic Energy, Department of Space, All important policy issues and all other portfolios not allocated to any Minister', 'NULL', 'NULL', 'NULL');
INSERT INTO table_name VALUES ( '102', 'Rajnath Singh', 'Cabinet Ministers', 'Home Affairs', 'NULL', 'NULL', 'NULL');
INSERT INTO table_name VALUES ( '103', 'Sushma Swaraj', 'Cabinet Ministers', 'External Affairs, Overseas Indian Affairs', 'NULL', 'NULL', 'NULL');
INSERT INTO table_name VALUES ( '104', 'Arun Jaitley', 'Cabinet Ministers', 'Finance, Corporate Affairs and Defence', 'NULL', 'NULL', 'NULL');

我编写了PHP代码,用于生成来自excel的所有查询,并为我们的生产系统点击了单击