0

I hope someone can help me with my SSIS automation error. I created a package that downloads a file from a webportal. In second step of my package, i convert that .xls to .csv(there is a valid reason for this conversion as downloaded .xls file can't be opened by package). I use below code to convert my File to csv and works perfectly fine on my local machine. But when i deploy it on server. It throws below error message. The only thing i could think of is that when i run it on my local machine, when it converts the file to csv, a message box pops up on the screen saying "converting the file" and then "saving the file as .csv". And server machine is having issues to deal with these message boxes ? Help will be appreciated. enter image description here

#region Namespaces
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.IO;
using System.Reflection;
using Excel = Microsoft.Office.Interop.Excel;
using System.Net;
#endregion

    public void Main()
    {
        // TODO: Add your code here

        Excel.Application excelapp = new Excel.Application();
        Excel.Workbook Datasource = (Excel.Workbook)excelapp.Workbooks.Add(1);

        var DownloadPath = Dts.Variables["User::varDownloadPathNew"].Value.ToString();
        var ConvertedPath = Dts.Variables["User::varConvertedFileName"].Value.ToString();

        string FileName = DownloadPath;
        var format = Excel.XlFileFormat.xlCSV;

        Datasource = excelapp.Workbooks.Open(FileName, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);

        Datasource.SaveAs(ConvertedPath, format, Missing.Value, Missing.Value, false, false, Excel.XlSaveAsAccessMode.xlNoChange,
        Excel.XlSaveConflictResolution.xlUserResolution, true,
        Missing.Value, Missing.Value, Missing.Value);

        //Clean
        Datasource.Close(true);
        System.Runtime.InteropServices.Marshal.FinalReleaseComObject(Datasource);

        excelapp.Quit();
        System.Runtime.InteropServices.Marshal.FinalReleaseComObject(excelapp);

        Dts.TaskResult = (int)ScriptResults.Success;
    }
user3482527
  • 227
  • 1
  • 2
  • 22

1 Answers1

0

Managed to resolve the issue eventually. Ended up creating below two folders on C drive and then restarting the Server machine after that (Note,i installed MS office on server machine first).

C:\Windows\System32\config\systemprofile\Desktop C:\Windows\SysWOW64\config\systemprofile\Desktop

This resolved the issue for me.

Thanks

user3482527
  • 227
  • 1
  • 2
  • 22