如何使用 Openrowset 函数从 Excel 读取值?
我正在使用 openrowset 函数阅读 Excel 工作表?
我的 Excel 工作表在常规类型列中有数值。由于某种原因,即使这些值具有值,也会被视为空值。我不知道为什么会发生这种情况。我查看了字段的格式,它们在 Excel 中设置为“常规”,我尝试将它们设置为“文本”,但这没有帮助。
我尝试将 Excel 源中的内容转换为 csv 格式的文本文件,但由于某种原因,包含数值的文本字段显示为空白(NULL)。
任何有关解决此问题的意见将不胜感激。
SET @Cmd = 'INSERT INTO Table_01
SELECT * FROM OPENROWSET(''Microsoft.Jet.OLEDB.4.0'', ''Excel 8.0;Database=' + @ExcelFilePath + ''',
''SELECT * FROM [Sheet1$]'')'
EXEC(@Cmd)
I am reading excel sheet using openrowset function?
My Excel sheet has numeric value in General Type Column. For some reason these values are brought over as nulls even though they have a values. I am not sure why this is happening. I looked into the format of the fields and they are set to General in Excel, I tried setting them to Text and that did not help.
I tried to bring the contents from the excel source to a text file in csv format and for some reason the Text field containing numeric value came out as blank (NULL).
Any inputs on getting this addressed will be much appreciated.
SET @Cmd = 'INSERT INTO Table_01
SELECT * FROM OPENROWSET(''Microsoft.Jet.OLEDB.4.0'', ''Excel 8.0;Database=' + @ExcelFilePath + ''',
''SELECT * FROM [Sheet1$]'')'
EXEC(@Cmd)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这与 TypeGuessRows 和 IMEX 有关:
TypeGuesssRows 可以在以下位置找到:
值 0 表示所有行。
This is to do with TypeGuessRows and IMEX:
TypeGuesssRows can be found at:
A value of 0 means all rows.