|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 2:00 PM
Points: 24,
Visits: 94
|
|
Hi, I need to export an Excel sheet with special formats (mandatory) where SQL is the source. I have achieved it using Scripts via script component in SSIS but my question is there any other way in doing it so. Please explain it if there is a way in doing it so. Thanks in advance:)
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Monday, February 04, 2013 8:47 AM
Points: 17,
Visits: 103
|
|
manibad (1/2/2013) Hi, I need to export an Excel sheet with special formats (mandatory) where SQL is the source. I have achieved it using Scripts via script component in SSIS but my question is there any other way in doing it so. Please explain it if there is a way in doing it so. Thanks in advance:)
What do you mean special Formats?
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 11:14 PM
Points: 6,706,
Visits: 11,738
|
|
The only way to format an Excel Workbook programmatically using SSIS is to leverage the Excel Object Model from a Script Task.
One technique I have used in the past however is to create a Workbook formatted the way I like and then use that to export into. When targetting an Excel Worksheet in an OLE DB Destination the formatting is ignored. So format your Workbook and save it as a "template" reachable by your SSIS package. In your SSIS package use a File System Task to copy the "template" into a new location and export your data from SQL Server into the copy.
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 2:00 PM
Points: 24,
Visits: 94
|
|
Special formats for example...in excel sheet if you choose "Special format" under that "Social security number" the data specified in such a column would be always in SSN format.. I think i am clear...shld i explain more... :)
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: Today @ 2:42 AM
Points: 4,239,
Visits: 9,482
|
|
opc.three (1/3/2013) The only way to format an Excel Workbook programmatically using SSIS is to leverage the Excel Object Model from a Script Task.
One technique I have used in the past however is to create a Workbook formatted the way I like and then use that to export into. When targetting an Excel Worksheet in an OLE DB Destination the formatting is ignored. So format your Workbook and save it as a "template" reachable by your SSIS package. In your SSIS package use a File System Task to copy the "template" into a new location and export your data from SQL Server into the copy.
+1 to this second idea.
Or, in a similar vein, have an Excel template which contains a 'Format' button & associated VBA code to allow the formatting to be done by whoever opens the Excel file after the export has completed
____________________________________________________________________________________________
Help us to help you. For better, quicker and more focused answers to your questions, consider following the advice in this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
If you are asking for help and your post does not contain a question, you should expect responses which do not contain any answers. Put a question mark in there somewhere - it's not rocket science.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 2:00 PM
Points: 24,
Visits: 94
|
|
opc.three (1/3/2013) The only way to format an Excel Workbook programmatically using SSIS is to leverage the Excel Object Model from a Script Task.
One technique I have used in the past however is to create a Workbook formatted the way I like and then use that to export into. When targetting an Excel Worksheet in an OLE DB Destination the formatting is ignored. So format your Workbook and save it as a "template" reachable by your SSIS package. In your SSIS package use a File System Task to copy the "template" into a new location and export your data from SQL Server into the copy.
Using file system task i was able to copy the file template from one location to other.Using data flow task i manipulated the source using source and then i coded to execute the file system task. In dataflow task, I sorted the data and then i connected with excel destination.Where the destination is the template. I am getting the output without special formats. Data flow task and file system task was completed successfully.
What to do for rectifying the above and obtaining the desired output.
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 11:14 PM
Points: 6,706,
Visits: 11,738
|
|
The formatting will be pre-set in the "template" file. Open your "template" in Excel, adjust the formatting so it appears as you would like (e.g. bold column headers, background colors, etc.), save the "template" xlsx file and then close Excel. Then re-run your SSIS package. The outcome should be that the output file, the one you loaded data to, should also contain the formatting taken from the "template".
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 2:00 PM
Points: 24,
Visits: 94
|
|
I will list out the things what i have done. 1.In data flow task,OLE DB source->Sort->Data conversion->Excel destination(target is Format.xlsx(template file)) 2.In file system task,Source path is Format.xlsx(template) and destination file name is destiny.xlsx.Here the destination file is the copy of template file. 3.Package will be executed in this order Dataflow task->File system task
Note:Format.xlsx was placed after assigning the special formats to the worksheet.
but still i am getting the exported file with general format.I dint get it with special formats.
Now please tell me where i went wrong.So that i will be able to rectify it and proceed without making error.
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 11:14 PM
Points: 6,706,
Visits: 11,738
|
|
manibad (1/7/2013) I will list out the things what i have done. 1.In data flow task,OLE DB source->Sort->Data conversion->Excel destination(target is Format.xlsx(template file)) 2.In file system task,Source path is Format.xlsx(template) and destination file name is destiny.xlsx.Here the destination file is the copy of template file. 3.Package will be executed in this order Dataflow task->File system task
Note:Format.xlsx was placed after assigning the special formats to the worksheet.
but still i am getting the exported file with general format.I dint get it with special formats.
Now please tell me where i went wrong.So that i will be able to rectify it and proceed without making error.
Pre-requisite: open Format.xlsx (template file) in Excel and apply formatting as needed. Save to disk in original location as original name Format.xlsx.
SSIS Workflow:
1. In file system task, set to Copy source path Format.xlsx (template file) to destination file name is destiny.xlsx (copy of template file). Here the destination file is the copy of template file. 2. In data flow task,OLE DB source->Sort->Data conversion->Excel destination (target is destiny.xlsx (copy of template file)) 3. Package will be executed in this order File system task->Dataflow task
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 2:00 PM
Points: 24,
Visits: 94
|
|
opc.three (1/7/2013)
manibad (1/7/2013) I will list out the things what i have done. 1.In data flow task,OLE DB source->Sort->Data conversion->Excel destination(target is Format.xlsx(template file)) 2.In file system task,Source path is Format.xlsx(template) and destination file name is destiny.xlsx.Here the destination file is the copy of template file. 3.Package will be executed in this order Dataflow task->File system task
Note:Format.xlsx was placed after assigning the special formats to the worksheet.
but still i am getting the exported file with general format.I dint get it with special formats.
Now please tell me where i went wrong.So that i will be able to rectify it and proceed without making error.
Pre-requisite: open Format.xlsx (template file) in Excel and apply formatting as needed. Save to disk in original location as original name Format.xlsx. SSIS Workflow: 1. In file system task, set to Copy source path Format.xlsx (template file) to destination file name is destiny.xlsx (copy of template file). Here the destination file is the copy of template file. 2. In data flow task,OLE DB source->Sort->Data conversion->Excel destination (target is destiny.xlsx (copy of template file)) 3. Package will be executed in this order File system task->Dataflow task
after performing the above steps too i am unable to achieve my goal. I am unable to find where is the error. actually special format is nothing but the formats such as Zipcode,zipcode+4,Home phone number and social security number... this is what i have to achieve...
|
|
|
|