c#当字符串数据超过255个字符时,插入Excel失败 [英] c# Error inserting to Excel when string data is more than 255 chars

查看:802
本文介绍了c#当字符串数据超过255个字符时,插入Excel失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想一些数据导出到Excel。我使用OLEDB 12. connectio字符串看起来像:

I am trying to export some data to Excel. I am using OLEDB 12. The connectio string looks like:

"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES;'"

和我使用INSERT查询。但每当在目标列中的数据超过255个字符,我得到一个异常

And I use an INSERT query. But whenever the data in a target column exceeds 255 chars, I get an exception.

Exception Details: System.Data.OleDb.OleDbException: The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data.

有一个类似的职位上SO:的 Excel中无法插入超过255个字符?但不是到C#,

There is a similar post on SO: Excel unable to insert more than 255 chars? but it is not into c#,

我也称为 http://support.microsoft.com/kb/213841,并没有得到任何解决方案。

I also referred to http://support.microsoft.com/kb/213841 and not getting any solution.

请帮忙。

推荐答案

我所做的最后:

由于我没有聚集足够的反应,并没有能够解决这个问题,我切换到Excel对象(办公室互操作),也没有问题了。

As I could no amass enough responses and was not able to solve the issue, I switched to Excel object (Office Interop) and there is no issue now.

这篇关于c#当字符串数据超过255个字符时,插入Excel失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆