Answer the question
In order to leave comments, you need to log in
SSIS. Why does the C# script not work when run through job. Options?
Good afternoon Colleagues.
There is a C# block with the following code that converts binary excel to normal:
string xlsb = Dts.Variables["$Project::FilePath2"].Value.ToString();
string xlsx = Dts.Variables["$Project::FilePath"].Value.ToString();
// init excel
Microsoft.Office.Interop.Excel.Application excelApplication = new Microsoft.Office.Interop.Excel.Application();
excelApplication.DisplayAlerts = false;
// open book in any format
Workbook workbook = excelApplication.Workbooks.Open(xlsb, XlUpdateLinks.xlUpdateLinksNever, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
// save in XlFileFormat.xlWorkbookDefault format which is XLSX
workbook.SaveAs(xlsx, XlFileFormat.xlWorkbookDefault, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
// close workbook
workbook.Close(false, Type.Missing, Type.Missing);
//excelApplication.DisplayAlerts = true;
// shutdown excel
excelApplication.Quit();
Convert xlsb -> xlsx:Error: Exception has been thrown by the target of an invocation.
Answer the question
In order to leave comments, you need to log in
Well, I would start by wrapping the code in a try-catch and dumping the exception and inner exeption into the log in detail while there is one.
https://stackoverflow.com/questions/28997381/runti... Look here
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question