OLEDB,写作的Excel没有领先的撇号电池 [英] OLEDB, Writing Excel cell without leading apostrophe

查看:191
本文介绍了OLEDB,写作的Excel没有领先的撇号电池的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用OLEDB(C#)写入Excel文件。 我需要的只是原始数据格式。

I'm writing to Excel file using OLEDB (C#). What I need is just RAW data format.

我注意到所有单元格(header和值)是由撇号pfixed $ P $(')

I've noticed all cells (headers and values) are prefixed by apostrophe (')

它是一种方式,以避免将它们中的所有文本单元格?

Is it a way to avoid adding them in all text cells?

这是我的连接字符串:

string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +  
 filePath + ";Extended Properties='Excel 8.0;HDR=Yes'";

我试着使用IMEX = 1是这样的:

string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +  
   filePath + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"";

不过,我收到下面的错误后认为:

But after that I'm receiving below error:

* Microsoft Jet数据库引擎找不到对象 C:\ TEMP \新建文件夹\ MF_2009_04_19_2008-11-182009_DMBHCSAM1118.xls
。 请确保对象存在并且,您拼写其名称和正确的路径名。*

*The Microsoft Jet database engine could not find the object 'C:\Temp\New Folder\MF_2009_04_19_2008-11-182009_DMBHCSAM1118.xls'.
Make sure the object exists and that you spell its name and the path name correctly.*

最后我试着使用IMEX = 0是这样的:

string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +  
   filePath + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=0\"";

这一次没有产生的异常升高。

This time no exeptions raised.

不幸的是,仍有问题撇号 (所以每次我的价值观看起来:123,ABC等)

Unfortunately there is still problem with apostrophes (so each my values looks as: '123, 'abc etc...)

你知道吗?

推荐答案

http://support.microsoft.com/kb/257819 有一个声明,大意是通过ADO插入文本到Excel时,此行为可能是不可避免的:

http://support.microsoft.com/kb/257819 has a statement to the effect that this behaviour might be unavoidable when inserting text into Excel via ADO:

有关编辑Excel数据使用ADO 一个警告:当你插入的文本数据到Excel使用ADO,文本值是preceded以一个单引号。这可能会导致在稍后与新的数据的工作的问题。

A caution about editing Excel data with ADO: When you insert text data into Excel with ADO, the text value is preceded with a single quote. This may cause problems later in working with the new data.

时的数据明确的文字,可能是被强制转换为数字格式? (抓着救命稻草......)

Is the data explicitly text, might it be coerced into a numeric format? (clutching at straws...)

这篇关于OLEDB,写作的Excel没有领先的撇号电池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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