Link to home
Start Free TrialLog in
Avatar of marketoneDev
marketoneDev

asked on

How do I get stop Excel columns from changing from TEXT to GENERAL when my data task within SSIS writes from an OLEDB to my Excel template file?

I have an SSIS package (2008 R2) where I have a SQL Server source writing to an Excel file. The Excel file is a template and all of the columns are TEXT. After the data is written to the Excel file the cells that now contain data have changed from TEXT to GENERAL. How do I prevent this so that all cells remain TEXT.
ASKER CERTIFIED SOLUTION
Avatar of Roy Cox
Roy Cox
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of marketoneDev
marketoneDev

ASKER

Hi Roy, I created the macro and it runs in the open event of the workbook. However, the file gets saved with a .xlsm extension which works fine outside of SSIS but my package is uses a data flow task to write to the Excel file from a SQL Server database.  Any suggestions as to how to get around this problem.  Thanks.
If SSIS doesn't recognise  the xlsm format then you could put the code into an addin and manually run the code when required.
The suggestion to run a simple macro to convert the cells back to Text is what I needed. However, I cannot run this manually as it is part of a scheduled SSIS package and SSIS does not recognize an .xslm file. I'm going to try to use a script task within SSIS using c# to see if that will work.