generated excel from SSIS but getting quote in eve

2019-02-15 17:28发布

I have generated and excel from SSIS package successfully. But every column is having extra ' (quote) mark why is it so?

enter image description here

My source sql table is like below

Name    price    address
ashu    123      pune
jkl     34       UK

In my sql table i took all column as varchar(50) datatype. In Excel Manager when it is going to create table Excel Destination took all column as same varchar(50) datatype.

And in Data Flow I have used Data Conversion transformation to prevent unicode conversion error.

Please advice where i need to change to get the clear columns in excel file.

4条回答
forever°为你锁心
2楼-- · 2019-02-15 17:29

First, define the field types for your excel destination in SSIS, any non-text fields will format properly without the '. Then, add a derived column transformation between your source and destination, and use a replace statement for any text columns. Should be:

(REPLACE(Column1, "'","")
查看更多
smile是对你的礼貌
3楼-- · 2019-02-15 17:30

You could create a template Excel file in which you have specified all the column types (change to Text from General) and headers you will need. Store it in a /Template directory and have copy it over to where you will need it from within the SSIS package.

In your SSIS package:

  1. Use Script Component to copy Excel Template file into directory of choice.
  2. Programatically change its name and store the whole filepath in a variable that will be used in your corresponding Data Flow Task.
  3. Use Expression Builder for your Excel Connection Manager. Set the ExcelFilePath to be retrieved from your variable.
查看更多
做自己的国王
4楼-- · 2019-02-15 17:46

This caused me major problems! So I completed the following: You can change the excel version to 'Microsoft Excel 4.0' within the excel connection manager in your SSIS package. Then within excel follow Options > Trust Center > Trust Center Settings > File Block Settings > Untick the 'Open' checkbox for 'Excel 4 workbooks' and 'sheets'.

查看更多
再贱就再见
5楼-- · 2019-02-15 17:55

the single quote or apostrophe is a way of entering any data (in Excel) and ensure it is treated as text so numbers with leading zeros or fractions are not interpreted by Excel as numeric or dates.

a NJ zip code for instance 07456 would be interpreted as 7456 but by entering it as '07456 it keeps its leading zero (please note that numbers in your example are left aligned, like text is)

I guess SSIS is adding the quotes because your data is of VARCHAR type

查看更多
登录 后发表回答