mysql load excel文件_是否有一种LOAD DATA INFILE(导入)xlsx文件到MySQL数据库表中的方法...

文章讨论了如何将Excel(.xls/.xlsx)文件导入到MySQL数据库,指出LOAD DATA INFILE命令不支持二进制文件。作者寻求解决方案,提到最简单的方法是先将Excel文件导出为CSV格式,然后使用LOAD DATA INFILE命令导入到数据库表中。
摘要由CSDN通过智能技术生成

bd96500e110b49cbb3cd949968f18be7.png

I know that this is discussed a lot but I don't find solution of how to do that.

What I need is to import an excel file (xls/xlsx) to my database table. It is a button which does that and the command which is executed is like that:

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

Thanks a lot

pepys

解决方案

.xls will never be importable directly into MySQL. it's a compound OLE file, which means its internal layout is not understandable by mere mortals (or even Bill Gates). .xlsx is basically just a .zip file which contains multiple .xml/xslt/etc. files. You can probably extract the relevant .xml that contains the actual spreadsheet data, but again - it's not likely to be in a format that's directly importable by MySQL's load infile.

The simplest solution is to export the .xls/xlsx to a .csv.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值