OLEDB,不带前导撇号编写Excel单元格 [英] OLEDB, Writing Excel cell without leading apostrophe
问题描述
我需要的只是RAW数据格式。
我注意到所有单元格(标题和值)都以撇号(')为前缀
这是一种避免在所有文本单元格中添加它们的方法?
这是我的连接字符串: strong>
string connectionString =Provider = Microsoft.Jet.OLEDB.4.0; Data Source =+
filePath +;扩展属性='Excel 8.0; HDR =是';
我试过使用IMEX = 1,如下所示:
string connectionString =Provider = Microsoft.Jet.OLEDB.4.0; Data Source =+
filePath +;扩展属性= \Excel 8.0; HDR = Yes; IMEX = 1\;
但之后,我收到以下错误:
Microsoft Jet数据库引擎找不到对象
'C:\Temp\New Folder\MF_2009_04_19_2008-11-182009_DMBHCSAM1118.xls'。
Make确保对象存在,并且您正确地拼写其名称和路径名。
最后我尝试使用IMEX = 0,如下所示:
string connectionString =Provider = Microsoft.Jet.OLEDB.4.0; Data Source =+
filePath +;扩展属性= \Excel 8.0; HDR =是; IMEX = 0\;
这次没有提出兴趣。
不幸的是,撇号
仍然有问题(所以我的每个值都会显示为:'123,'abc etc ...)
任何想法?
http://support.microsoft.com/kb/257819 有一个声明,表示通过ADO将文本插入到Excel中时,这种行为可能是不可避免的:
关于使用ADO编辑Excel数据的警告 :当您使用ADO将文本数据插入到Excel中时,文本值前面加上单引号。这可能会在使用新数据后出现问题。
数据是否明确显示文字,可能会被强制为数字格式吗? (抓住吸管...)
I'm writing to Excel file using OLEDB (C#). What I need is just RAW data format.
I've noticed all cells (headers and values) are prefixed by apostrophe (')
Is it a way to avoid adding them in all text cells?
Here is my connection string:
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
filePath + ";Extended Properties='Excel 8.0;HDR=Yes'";
I've tried use IMEX=1 like this:
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:
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.
Finally I've tried use IMEX=0 like this:
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.
Unfortunately there is still problem with apostrophes (so each my values looks as: '123, 'abc etc...)
Any idea?
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:
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屋!