using Excel = Microsoft.Office.Interop.Excel;
Excel.Application App = null;
Excel._Workbook WB = null;
Excel._Worksheet WS = null;
//Start Excel and get Application object.
App = new Excel.Application();
App.Visible = true;
//Get a new workbook.
WB = (Excel._Workbook)(App.Workbooks.Add(Missing.Value));
WS = (Excel._Worksheet)WB.ActiveSheet;
//Getting data from datatable using string[,] arrFromTable
WS.get_Range("A2", endRange).Value2 = arrFromTable;
string ExcelFileName = DateTime.Now.Ticks + "s" + App.UserName.GetHashCode().ToString() + ".xls";
WB.SaveAs(loginUri, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, null, null, null, null, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, null, null, null, null, null);
WB.Close(false, null, null);
App.Quit();
The SaveAs method doesnt throw any exception but the file will not be saved in the destination as the browser will not respond at this step and finally timeout.
Could there be any other method to save the excel file in the Sharepoint document library? What could be going wrong in the above method?
Thanks and Regards.