SSIS 2008 Excel 源 - 加载字母数字列时出现问题

发布于 2024-10-20 01:34:23 字数 542 浏览 3 评论 0原文

我正在使用 SSIS 2008Excel 加载字母数字列。

我有一列从整数开始,

1
2
...
999

然后更改为 AlphaNumeric

A1
A2
A999

当我尝试使用 Excel 数据源 进行加载时,Excel 总是会说它是一个 整数,因为它必须仅对文件的顶部进行采样。
(顺便说一句 - 我知道我可以重新排序文件,以便阿尔法位于顶部,但我宁愿不必这样做......)

不幸的是,您似乎无法改变主意。这意味着当它加载数据时,它会过滤掉 'A' 并且 A999 记录将更新 999 记录。这显然不太好... 我尝试在高级编辑选项下将外部列和输出列更改为字符串,但出现错误,并且在将列设置回整数之前它不会运行。

有人有解决办法吗?

I am using SSIS 2008 to load alphanumeric columns from Excel.

I have one column which starts off as integer

1
2
...
999

Then changes to AlphaNumeric

A1
A2
A999

When I try to load using using an Excel Data Source, excel will always say that it is an integer as it must only sample the top of the file.
(BTW - I know that I can re-order the file so that the alphas are at the top but I would rather not have to do this...)

Unfortunately you can't seem to be able to change its mind. This means that when it loads the data, it filters out the 'A' and the A999 record will update the 999 record. This is obviously not good...
I have tried to change the external and output columns to string under the advanced editing options, but I get errors and it won't run until you set the columns back to integer.

Does anyone have a solution?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

壹場煙雨 2024-10-27 01:34:23

SSIS 使用 Jet 访问 Excel 文件。默认情况下,Jet 会扫描数据的前 8 行以确定每列的类型。

要修复此问题,您需要编辑注册表以增加以下注册表项之一的TypeGuessRows DWORD值,以确定要扫描数据的行数

:取决于 Windows 版本和 excel 版本...如下所示:

For 32-bit Windows

Excel 97
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\3.5\Engines\Excel

Excel 2000 and later versions
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Excel

For 64-bit Windows

Excel 97
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Jet\3.5\Engines\Excel

Excel 2000 and later versions
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Jet\4.0\Engines\Excel

然后,在连接字符串中指定 IMEX=1,如下所示:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\abc.xls;
Extended Properties="EXCEL 8.0;HDR=YES;IMEX=1";

可以在以下位置找到更详细的信息:< a href="http://support.microsoft.com/kb/189897/" rel="nofollow">http://support.microsoft.com/kb/189897/

SSIS uses Jet to access the Excel files. By default, Jet scans the first 8 rows of your data to determine the type of each column.

To fix it, you will need to edit the registry to increase the TypeGuessRows DWORD value of one of the following registry keys to determine how many rows to scan in your data:

It depends on what version of Windows and what version of excel ... as follows:

For 32-bit Windows

Excel 97
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\3.5\Engines\Excel

Excel 2000 and later versions
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Excel

For 64-bit Windows

Excel 97
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Jet\3.5\Engines\Excel

Excel 2000 and later versions
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Jet\4.0\Engines\Excel

Then, specify IMEX=1 in the connection string as follows:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\abc.xls;
Extended Properties="EXCEL 8.0;HDR=YES;IMEX=1";

This information can be found in a more verbose form at: http://support.microsoft.com/kb/189897/

谁人与我共长歌 2024-10-27 01:34:23

哇,这看起来真是一个巨大的痛苦。我遇到了几个示例,您可以更改连接字符串,有时会获得更好的结果,但它们似乎并不适合所有人。

编写自动转换为 .csv 文件的脚本将是一个很好的解决方法,此线程中有许多建议:

在没有 GUI 的情况下将 Excel (xls) 文件转换为逗号分隔 (csv) 文件

包括您使用的一些 C# 代码也许能够轻松进入:

http://jarloo.com/code /api-code/excel-to-csv/

这是一个类似的问题,如果您想自己研究一下,则讨论更改连接字符串:SSIS Excel 导入强制不正确的列类型

祝你好运!

Wow, that looks like a huge pain. I came across a couple of examples where you could alter the connection string and sometimes get better results but they don't seem to work for everyone.

Scripting an automatic conversion to an .csv file would be a good workaround, there are a number of suggestions in this thread:

converting an Excel (xls) file to a comma separated (csv) file without the GUI

including some code in C# that you may be able to easily plop in:

http://jarloo.com/code/api-code/excel-to-csv/

here is the simiar question where altering the connection string is discussed if you want to look into it for yourself: SSIS Excel Import Forcing Incorrect Column Type

Good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文