generated excel from SSIS but getting quote in every column?

前端 未结 4 1491
小蘑菇
小蘑菇 2020-12-18 10:43

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

相关标签:
4条回答
  • 2020-12-18 11:23

    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

    0 讨论(0)
  • 2020-12-18 11:24

    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.
    0 讨论(0)
  • 2020-12-18 11:30

    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'.

    0 讨论(0)
  • 2020-12-18 11:33

    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, "'","")
    
    0 讨论(0)
提交回复
热议问题