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

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

问题描述

我正在尝试将一些数据导出到Excel。我正在使用OLEDB 12.连接字符串看起来像:

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.

请帮助。

推荐答案

p> 我最终做了什么:

由于我无法收集足够的回复,无法解决问题,我切换到Excel对象(Office Interop),现在没有问题。

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天全站免登陆