使用OleDb写入Excel异常,"字段太小而不能接受所要添加的数据的数量" "the field is too small to accept the amount of data "
来源:互联网 发布:js 正则提取字符串 编辑:程序博客网 时间:2024/05/21 10:03
解决方法:
excel是根据第一行数据来判断数据类型的,所以你需要在第一行相应字段添加足够长的字符串(随便写长一点就行,导入后可以删除的嘛).
这个问题是Access数据库字段默认长度是250,而你添加的数据大于250个字符,但是你是通过Access驱动引擎写入到Excel的,所以你也无法改变数据类型.
在网上找问题,很多人都说改变Access字段数据类型,问题是我根本就没有在Access上操作,而是通过Access驱动引擎写入到Excel里面.所以解决思路应该放在Excel上.
这样就搞定了.
还有一个异常:标准表达式中数据类型不匹配。
同理:原因就是第一行记录为空或者为数字,所以要改为字符串.将第一行记录添加数据,
这是我在google找到的.
=============================
参考:https://www.inaplex.com/forum/yaf_postst4_Excel-ODBC-error----The-field-is-too-small.aspx
While importing from an Excel spread sheet you see the following error message:
- "[Microsoft][ODBC Excel Driver] The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data".
This is problem with the Excel ODBC driver which can often be worked around by reordering the records in the spreadsheet.
Fundamentally, Excel is NOT a database and the columns in a spreadsheet do not have a data type associated with them in the same way that that a database does. The Excel ODBC driver has to make an assumption about the data type for a given column. The driver does this by reading ahead 8 records and looking at the data found. It then makes a decision about the data type based upon what it has read. Problems occur when the assumption about data type is proven wrong by subsequent records. Consider two scenarios….
- A column in an Excel spreadsheet has a column in it which contains string data. The first 8 records contain short strings, (let's say 20-30 characters). The Excel ODBC driver reads this data and assumes that a short string data type will be appropriate for this column. If a subsequent record contains a longer string, (let's say 300 characters). The data type may prove inappropriate and unable to store the longer string and the error above is raised by the Excel ODBC driver. Moving the record with the long string to the beginning of the dataset will allow the Excel ODBC to select a more appropriate data type for the column which will apply to all records in the spreadsheet.
- A column in a spreadsheet has numeric strings for the first 8 records, For example "123", "456" etc. Excel decides that this column has numeric data. A subsequent record contains a string which is not numeric data, for example "Hello World". The assumption made by the Excel ODBC driver will prove incorrect and the above error message will be raised by the ODBC driver. The problem can be worked around by reconsidering the order of the records. If the record containing "hello world" is placed within the first 8 records. The Excel ODBC driver will determine that this column contains string data and hopefully a string data type will be selected which will be appropriate for all data records.
In all cases the technique is to arrange the order of the records such that the Excel ODBC driver is allowed to make the correct selection of data type.
0 0
- 使用OleDb写入Excel异常,"字段太小而不能接受所要添加的数据的数量" "the field is too small to accept the amount of data "
- access查询时字段太小而不能接受所要添加的数据的数量
- sql server 2000 导入excel时错误,字段太小而不能接受所要添加的数据的数量。试着插入或粘贴较少的数据.
- Asp.net字段太小而不能接受所要添加的数据的数量的解决方案
- 字段太小而不能接受所要添加的数据的数量。试着插入或粘贴较少的数据。
- pl sql developer 导入excel 字段太小而不能接受所添加的数据的变量
- asp.net 导出数据到excel报“段太小而不能接受所要添加的数据的数量。试着插入或粘贴较少的数据”错误的解决方法
- The Devil is in the Details: Nuances of Light Mapping
- The copy directory is too small
- xxx cannot be resolved or is not a field问题的解决方案
- Oracle ORA-01873: the leading precision of the interval is too small 解决办法
- AIX中The largest dump device is too small的处理
- AIX中The largest dump device is too small的处理
- Accept-Encoding: gzip, deflate
- 关于Location of the Android SDK has not been setup in the preferences的解决方法
- Choreographer: Skipped 129 frames! The application may be doing too much work on its main thread.
- What is the function MultiplyUV() in shader?
- Oledb 写入Excel异常 INSERT INTO 语句的语法错误。
- HDU 1176(动态规划)
- newInstance 和 new的 区别
- 从上往下打印二叉树
- ubuntu mysql远程连接
- 不能直接ssh远程连接远端ubuntu 16.04.1的解决办法
- 使用OleDb写入Excel异常,"字段太小而不能接受所要添加的数据的数量" "the field is too small to accept the amount of data "
- 对js cookie的一些理解
- HandlerThread 的使用
- ubuntu 修改mysql编码为utf8
- android studio导入PullToRefresh教程
- YII 下url 美化
- VIM键盘映射 (Map)
- Tomcat报错 Caused by: java.lang.NoSuchMethodError
- FusionCharts简单教程(二)-----使用js加载图像和setDataXML()加载数据