遭遇ASP.NET(C#)Excel导入Dataset的数据值丢失问题(Excel to Dataset混合字段的格式问题)
作者: 李嘉 日期: 2010-05-06 23:51
最近TCAT Survey项目中,Excel数据导入遭遇到了一个问题,从Excel导入的数据中有部分数据丢失。如下图所示,ZIP字段明明设置了是文本格式,但是导入到数据库中去时似乎因为存在格式问题二导致部分数据导入为空,大致是混合字段的格式问题,如何解决?只需要在Excel to Dataset的时候,加一个IMEX=1的字符串,如下图所示,含义是“IMEX = 1; 告诉系统如一个列中有数字和文本 就是“混合”数据列, 那么都作为文本来对待”,OK,这样导入就能正常导入了。
另外一个参数HDR=Yes; 告诉系统表示第一行包含columnnames,而不是数据。
You need to use IMEX attribute, If your excel is 2003, then excel library version is 11.0, but 8.0 should also be fine. Try the below things
Extended Properties='Excel 8.0;IMEX=1'; The single quotes should start after = and end after 1. If this does not work try the below
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:MyExcel.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""
"HDR=Yes;" indicates that the first row contains columnnames, not data.
"IMEX=1;" tells the driver to always read "intermixed" data columns as text
订阅
上一篇
返回
下一篇

标签:

云计算平台搭建方案一(概览版VMWare+Citrix) (2011-08-29 21:21)
VS.NET2003在SVN版本管理下出现“项目刷新失败,无法从服务器中检索文件夹信息”的解决方案 (2011-06-14 00:48)
Window 2008 远程连接提示"Remote Desktop cannot connect ... the authentication certificate received ... expired or invalid" (2011-01-30 01:30)
Windows 7无法和设备或资源(主DNS服务器)通信的解决方法 (2010-11-07 20:59)
Windows 7和WinXP关机时候总是提示“结束程序”很麻烦能否取消或关闭 (2010-11-01 22:57)
win2008安装软件时the filename, directory name, or volume label syntax is incorrect错误解决方案 (2010-10-28 19:19)
微软ASP.NET 爆出新安全漏洞(Microsoft Security Advisory (2416728))攻击者可访问任意文件 (2010-09-19 07:47)
Internet Explorer 9 Beta版本文本框拖拽功能BUG以及IE9的Javascript兼容问题转IE8模式解决方案 (2010-09-18 18:23)
编译生成出现Unsafe code may only appear if compiling with /unsafe在VS.NET 2005/2008/2010中的问题解决方案 (2010-09-18 17:54)