English 中文(简体)
是否有办法将进出口的Xlsx文档输入MySQL数据库表
原标题:Is there a way of LOAD DATA INFILE (import) xlsx file into MySQL database table

我知道,这个问题已经讨论了很多,但我没有找到如何这样做的解决办法。

我需要的是向我的数据库表输入一个Excel文档(xls/xlsx)。 它是个县,所执行的指挥机关是:

 string cmdText = "LOAD DATA INFILE  importTest4MoreMore.csv  INTO TABLE management FIELDS TERMINATED BY  , ;";

It works great. But I need to import excel file not CSV. As far as I know LOAD DATA command does not support binary files which xls is. So what s the solution to that? Please help

非常感谢

pepys

最佳回答

xls永远不会直接进口到MySQL。 它是一个复合的OLE档案,这意味着其内部布局不能仅仅通过摊销(甚至比尔·盖茨)来理解。 xlsx基本上只是一个含有多个xml/xslt/etc文档的齐p文档。 也许,你可以提取含有实际电子表格数据的相关xml,但又一次——它不太可能采用由MySQL的装货单直接进口的格式。

最简单的解决方法是将xls/xlsx出口到csv。

问题回答

• 如何将Xlsx文档输入MySQL:

1/ 开放您的xlsx档案办公室 Excel,从菜单中点击“拯救儿童联盟”

  CSV (MS-DOS) (*.csv)  

页: 1 最后点击 Save button.

2/ 制版或上载MySQL服务器中的C.csv文档(一条像:/root/someDirectory/ inlav服务器中的目录)

3/login to You database:

mysql -u root -pSomePassword

4/ 建立和使用目的地数据库:

use db1

5/ 在您的目的地数据库(如db1)上建立一个MySQL表,上面C.sv文档的栏目。

6/不包括以下指挥:

LOAD DATA INFILE  /root/someDirectory/file1.csv  INTO TABLE `Table1` FIELDS TERMINATED BY  ,  ENCLOSED BY  "  LINES TERMINATED BY  
  IGNORE 1 LINES;

请注意,“签字”1 LINES”方案指出,MySQL无视第1条档案。 因此,只有Xxx文档,有1个标题栏。 你可以取消这一选择。

http://www.devart.com/dbforge/mysql/studio/data-export-import.html 这一工具直接打开Excel文档,不使用COM接口,支持指挥线。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签