1

我有一个在 Excel 工作表中动态创建和填充数据的方案。数据在 Sql Server 中可用。我将 Sql 表数据捕获到对象变量中,然后在使用 Excel 连接执行 Sql 任务中,我如何将此对象变量用作表来执行select * into SheetName from [User::Object]

注意:列名不是恒定的。它们每次运行都会改变。

4

1 回答 1

1

There are a few ways to get this task done:

  1. Via ADO Enumerator:

    By using the foreach loop task and choosing ADO Enumerator.

    An example: Implementing Foreach Looping Logic in SSIS


  1. The data source as an ADO recordset:

    This is perhaps a harder way because the data source to be created programmatically using C# by parsing incoming object variable. Then, it can be used to load data into excel destination by leveraging a mere dataflow:

enter image description here

An example: Using The SSIS Object Variable As A Data Flow Source


Update: Because of new requirement - column names are dynamically assigned:

The Excel file also to be programmatically created using C#:

  1. How to create Excel file in C#
  2. Create Excel Files in C#
于 2019-09-11T07:28:59.030 回答