简体   繁体   English

跳过行:将数据从SSIS导出到excel文件中

[英]Skip rows: Export data from SSIS into excel file

I am trying to export data from a SQL server database into an excel file using SSIS. 我正在尝试使用SSIS将数据从SQL Server数据库导出到excel文件中。 I want the data to get inserted from the 6th row and 5th row has headers. 我想从第6行插入数据,第5行有标题。

在此输入图像描述

I am able map the header names, in Excel Destination Editor , to the SQL table headers, by writing the SQL command: 通过编写SQL命令,我可以将Excel目标编辑器中的标题名称映射到SQL表头:

SELECT * FROM [Sheet1$A5:EC5]

But still, when I execute the package, the data gets inserted from the 2nd row How can I start the insertion from 6th row? 但是,当我执行包时,数据从第2行插入如何从第6行开始插入?

Any help, to solve this, is appreciated. 任何帮助,解决这个,是值得赞赏的。 Thanks in advance! 提前致谢!

Add the blank rows to the dataset in OLE DB source in SSIS. 将空行添加到SSIS中OLE DB源中的数据集。 I assume that your columns in your database are named Header1, Header2 and Header3. 我假设您的数据库中的列名为Header1,Header2和Header3。 Replace your OLE DB source query with this query: 用此查询替换OLE DB源查询:

 select ' ' as Header1, ' ' as Header2, ' ' as Header3
 UNION ALL
 select ' ', ' ', ' '
 UNION ALL
 select ' ', ' ', ' '
 UNION ALL
 select ' ', ' ', ' '
 UNION ALL
 select ' ', ' ', ' '
 select Header1, Header2, Header3 from Your_SQL_SERVER_Tabl

You may need to cast your columns to varchar if they are of other types. 如果列为其他类型,则可能需要将列转换为varchar。

你需要为excel源使用“OpenRowset”属性,转到excel源的属性页面,将“OpenRowSet”设置为“$ A6:D”,然后它应该解决你的问题。

I've had a similar issue trying to export to Excel from SSIS. 我有一个类似的问题试图从SSIS导出到Excel。 I ended up going the third-party route by purchasing the "Export Excel Task" from ZappySys. 我最终通过从ZappySys购买“Export Excel Task”来进入第三方路线。 It allows you to specify the cell offset to start at. 它允许您指定要从头开始的单元格偏移量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM