0

i have a script task in ssis pacakge. Code of the script task :

          string xlsPath = Dts.Variables["User::FilePath"].Value.ToString();

            Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();
            app.Visible = false;
            Microsoft.Office.Interop.Excel.Workbook workbook = app.Workbooks.Open(xlsPath);
            Microsoft.Office.Interop.Excel.Worksheet worksheet = workbook.Worksheets[1];
            int ColumnIndex = 4;
            worksheet.Columns[ColumnIndex].TextToColumns();
            worksheet.Columns[ColumnIndex].NumberFormat = "0";
            workbook.Save();
            workbook.Close();

I am having no problem while running package in VS2015, but when running it through sql agent it is throwing the following error :

Exception from HRESULT: 0x800A03EC.

I am using xls file.

Ankit Tyagi
  • 129
  • 12

1 Answers1

1

You can add try...catch... in your script, to catch the exact error message.

It might be caused by permission issue, the account used in the agent job(SQL Server Agent Service Account by default) doesn't have access to the Excel file.

The solution is to run the package using a Proxy Account, which is given enough permissions.

How to create a Proxy Account and use it to run SSIS package

Yang.Z
  • 101
  • 1
  • 14