SQL Server 2005 SSIS 数据传输 SQL 到 Excel 损坏 Excel 文件

发布于 2024-08-17 17:57:05 字数 796 浏览 3 评论 0原文

我有一个 SSIS 包,它将数据从 SQL Server 2005 数据库上的表导出到 Excel 电子表格。 相关电子表格有 15 张工作表,我正在尝试在其中一张工作表上填充值。

我有一个模板文件,我将其克隆为导出的目标(一个简单的文件系统任务)。该模板文件有效且未损坏。

然后我有我的数据流任务,它使用 SQL 查询作为数据源。如果我预览一下,一切都很好。然后,我删除除一列之外的所有列(int 数据类型)。

我有一个 Excel 数据源(这是上面提到的目标电子表格),我将这两个数据源链接起来,跨过所选的单列。当我预览时,我得到第一个提示,表明出现了问题:

显示预览时出错。

其他信息:

索引和长度必须引用位置

参数名称:长度 (mscorlib)

当我运行该包时,它运行正常,报告我复制了 1 行。当我打开电子表格时,出现以下错误:

文件错误:数据可能已丢失

但是电子表格仍然会加载,当我转到我一直在尝试填充的工作表时,它已创建包含来自不同工作表的文本的新列。

当我尝试使用 SSIS 包中的整个列列表时,它似乎从电子表格的其他区域提取数据,这使我相信该过程在某种程度上损坏了电子表格。

我最初的想法是,这可能是由于尚未部署服务包而导致的问题,但我在 SQL 2005 RTM 和 SP3 安装上观察到了这种行为,并且有点卡住了。

我将非常感谢任何有类似经历并可能提供帮助的人。谢谢

I have an SSIS package that exports data from a table on a SQL Server 2005 database to an Excel Spreadsheet.
The spreadsheet in question has 15 sheets, and I am trying to populate values on one of these sheets.

I have a template file which I clone to be the target for the export (a simple file system task). This template file is valid, and is not corrupt.

I then have my data flow task, which uses a SQL Query as the data source. If I preview this, everything is fine. I then elimine all but one of the columns (an int data type).

I have an excel data source (which is the target spreadsheet as mentioned above), and I link the two, carrying across the single column selected. When I preview, I get the first hint that something is wrong:

There was an error displaying the preview.

ADDITIONAL INFORMATION:

Index and length must refer to a location within the string.

Parameter name: length (mscorlib)

When I run the package, it goes through ok, reporting that I have 1 row copied across. When I open the spreadsheet, I get the following error:

File Error: data may have been lost

The spreadsheet still loads however, and when I go to the sheet I have been attempting to populate, it has created a new column with text from a different sheet.

When I try with the entire list of columns in the SSIS package, it appears to pull data from other areas of the spreadsheet, which leads me to believe that the process is somehow corrupting the spreadsheet.

My initial thought was that maybe this was an issue with the fact that a service pack had not been deployed, but I have observed this behaviour on a SQL 2005 RTM and SP3 installs, and am a little stuck.

I would be very grateful to anyone that who has had similar experiences and might be able to help. Thanks

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

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

发布评论

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

评论(4

一身软味 2024-08-24 17:57:06

我有一个 Excel 数据源(这是上面提到的目标电子表格),我将这两个数据源链接起来,跨过所选的单列。当我预览时,我首先得到一些错误的提示:

显示预览时出错。

其他信息:

索引和长度必须引用字符串中的位置。

参数名称:长度(mscorlib)

当我运行该包时,它运行正常,报告我复制了 1 行。当我打开电子表格时,出现以下错误:

文件错误:数据可能已丢失

您是否尝试过重新创建此目标组件?这将是一个很好的起点,听起来它已经损坏了(不确定“损坏”是否是正确的词,但我发现这种情况在 SSIS 中经常发生)。在探索其他可能性之前,我通常会尝试更换有问题的组件。

I have an excel data source (which is the target spreadsheet as mentioned above), and I link the two, carrying across the single column selected. When I preview, I get the first hint that something is wrong:

There was an error displaying the preview.

ADDITIONAL INFORMATION:

Index and length must refer to a location within the string.

Parameter name: length (mscorlib)

When I run the package, it goes through ok, reporting that I have 1 row copied across. When I open the spreadsheet, I get the following error:

File Error: data may have been lost

Have you tried recreating this destination component? That'd be a good place to start, it sounds like it has become corrupt (not sure if corrupt is the proper word but it happens a lot in SSIS I've found). I usually try replacing the problem components before exploring other possiblities.

坦然微笑 2024-08-24 17:57:06

当我尝试使用 SSIS 查看 Excel 文件的预览时,会出现此消息。

我找到的解决方案是更改工作表的名称。

它必须以字母开头,并且必须删除所有空格。

This message appear to me when I try to see the preview of an Excel file with SSIS.

The solution that I found is to change the name of the sheet.

It has to start with a letter and you have to remove all the spaces.

时常饿 2024-08-24 17:57:05

我们已经查清了这件事的真相。

为了使数据以正确的格式显示,电子表格开发人员将隐藏的一行值作为电子表格的第一行。如果您希望数字是数字等,则必须执行此操作。

因此,在列为数字的单元格中放置了 0,在日期列的每个单元格中放置了一个日期,并在日期列的每个单元格中放置了一个撇号 (' ) 对于所有文本列。

后者并不是绝对必要的,当它们被删除时,电子表格似乎开始工作。

然而,其特殊之处在于电子表格在整个运输环境中都可以正常工作。只是在本地开发过程中才出现问题。

如果有人能够进一步阐明这是为什么,那么我们将不胜感激。

We got to the bottom of this.

In order to get the data appearing in the correct format, the spreadsheet developer had a hidden row of values as the first row of the spreadsheet. This is something that you have to do if you want your numbers to be numbers, etc.

So, a 0 had been placed in cells whose column was to be numeric, a date in each cell of a date column, and an apostrophe (') for all the text columns.

The latter wasn't strictly necessary, and when they were removed, the spreadsheet appeared to start working.

The peculiarity of this, however, is that the spreadsheet worked ok throughout the shipping environments. It was only during local development that then problem occurred.

If anyone could shed any more light on why this is, then it would be much appreciated.

↙厌世 2024-08-24 17:57:05

我在预览中遇到了完全相同的错误:

“索引和长度必须引用字符串中的位置。

参数名称:长度(mscorlib)”

Excel 文件中的工作表名称之一包含空格字符和连字符。哪一张纸有空格或连字符并不重要,因为我必须删除所有这些才能使用预览。

I had the exact same error in the preview:

"Index and length must refer to a location within the string.

Parameter name: length (mscorlib)"

One of the sheetnames in the Excel file contained a whitespace character as well as a hyphen. It didn't matter which sheet had the whitespace or hyphen as I had to remove all of them in order to use the preview.

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