s**********o 发帖数: 14359 | 1 SSIS要每天输出一个动态的EXCEL,比如REPORT20131001.XLS, REPORT20131002.XLS
等等,这个SSIS的DATA FLOW TASK居然HANDLE不了动态的EXCEL DESTINATION,
非要搞个TEMPLATE, COPY FILE,或者用CMDSHELL去创建,这也太土了,
这么一个基本的报表输出问题,都这么费劲 |
b******g 发帖数: 3883 | 2 你水平不行啊,是可以的。google create dynamic excel ssis
【在 s**********o 的大作中提到】 : SSIS要每天输出一个动态的EXCEL,比如REPORT20131001.XLS, REPORT20131002.XLS : 等等,这个SSIS的DATA FLOW TASK居然HANDLE不了动态的EXCEL DESTINATION, : 非要搞个TEMPLATE, COPY FILE,或者用CMDSHELL去创建,这也太土了, : 这么一个基本的报表输出问题,都这么费劲
|
s**********o 发帖数: 14359 | 3 GOOGLE了半天都是失败的,其实很明显,没有EXCEL FILE之前
就没法MAPPING到EXCEL的TAB里去
【在 b******g 的大作中提到】 : 你水平不行啊,是可以的。google create dynamic excel ssis
|
b******g 发帖数: 3883 | 4 http://social.msdn.microsoft.com/Forums/sqlserver/en-US/bda433a
Steps:
1. Click on package properties. Set "DelayValidation" property to True.
The package will not validate tasks, connections, until they are executed.
2. Create a package level variable "XLFileRootDir" as string and set it to
the root
directory where you want the excel file to be created.
Example: C:\Project\Data\
3. Create an Excel connection in the connection manager. Browse to the
target directory
and select the destination XL filename or type it in. It doesn't matter if
the file doesn't exist.
4. Go to the Excel connection properties and expand the expressions ellipse
(The button
with "..." on it).
Under the property drop down, select 'ExcelFilePath' and click on the
ellipse to
configure the expression:
@[User::XLFileRootDir] + (DT_WSTR, 2) DATEPART("DD", GETDATE()) + (DT_WSTR,
2) DATEPART("MM", GETDATE()) + (DT_WSTR, 4) DATEPART("YYYY", GETDATE()) +".
xls"
This should create an xl file like 01132007.xls.
5. Add a SQL task to package and double click to edit.
In the general tab, set 'ConnectionType' to 'Excel'.
For 'SQLStatement', enter the create table SQL to create destination table.
For example:
CREATE TABLE `Employee List` (
`EmployeeId` INTEGER,
`EmployeeName` NVARCHAR(20)
)
Copy the create table command. It will come in handy later.
6. Add a Data Flow task. In the data flow editor, add an OLEDB source and an
Excel destination.
Configure the source to select EmployeeId and EmployeeName from a table.
7. Connect this to Excel destination. In the destination editor, select the
Excel connection in the
manager, choose 'table or view' for data access mode and for 'name of the
Excel sheet' click on
new button and paste the create table command from Step 5.
Map the columns appropriately in the mappings tab and you are done. |
s**********o 发帖数: 14359 | 5 问题出在最后一部的MAPPING上,根本就不能选NAME OF THE EXCEL SHEET
直接就INVALID ARGUMENT了,因为EXCEL FILE不存在,所以根本没有SHEET可选,
没有SHEET怎么MAPPING |
s**********o 发帖数: 14359 | 6
【在 s**********o 的大作中提到】 : 问题出在最后一部的MAPPING上,根本就不能选NAME OF THE EXCEL SHEET : 直接就INVALID ARGUMENT了,因为EXCEL FILE不存在,所以根本没有SHEET可选, : 没有SHEET怎么MAPPING
|
s**********o 发帖数: 14359 | 7 根本就没有第七步的OPTION就ERROR掉了 click on
new button and paste the create table command from Step 5.
Map the columns appropriately in the mappings tab and you are done. |
b******g 发帖数: 3883 | 8 我刚才做了一下是works,我是sql server 2008 bids,在"name of excel sheet" 右边
有个 new ,不知道你的为啥没有,你和oledb source 连了吗?
【在 s**********o 的大作中提到】 : 根本就没有第七步的OPTION就ERROR掉了 click on : new button and paste the create table command from Step 5. : Map the columns appropriately in the mappings tab and you are done.
|
s**********o 发帖数: 14359 | 9 我的EXCELFILEPATH有些问题,因为是两个USER VARIABLE链接起来的,其实是@PATH+@
FILENAME,EVALUATE的话不出值,不过CREATE TABLE就是CREATE EXCEL FILE了,
CONNECT STRING显示这个
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=;Extended Properties="EXCEL 12
.0;HDR=YES"; |
b******g 发帖数: 3883 | 10 你data source 不应该是空的,应该是
c:\temp\4102013.xlsx
【在 s**********o 的大作中提到】 : 我的EXCELFILEPATH有些问题,因为是两个USER VARIABLE链接起来的,其实是@PATH+@ : FILENAME,EVALUATE的话不出值,不过CREATE TABLE就是CREATE EXCEL FILE了, : CONNECT STRING显示这个 : Provider=Microsoft.ACE.OLEDB.12.0;Data Source=;Extended Properties="EXCEL 12 : .0;HDR=YES";
|
s**********o 发帖数: 14359 | 11 是EXCELFILEPATH的问题,链接的USER VARIABLES不能EVALUE出值来,
改好了,不需要NEW了,我在DATA FLOW之前用了个CREATE TAB的
SQL TASK,谢谢你啊 |