I have an excel file that has pivot tables and charts in "Sheet 1" that reference the data from "Sheet 2", which in turn point to the records in the SQL Server table.
I wrote an SSIS job to populate a SQL Server base table, and then updated the excel sheet using the following code.
//At this point, sql server table is already populated with data. Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application(); excelApp.DisplayAlerts = false; excelApp.Visible = false; Workbook excelWorkbook = excelApp.Workbooks.Open(workbookPath, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value); try { excelWorkbook.RefreshAll(); excelWorkbook.RefreshAll(); excelWorkbook.RefreshAll(); excelWorkbook.Save(); } finally { excelWorkbook.Close(false, workbookPath, null); System.Runtime.InteropServices.Marshal.ReleaseComObject(excelWorkbook); excelWorkbook = null; excelApp.Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp); excelApp = null;
The problem is when I open excel, it still shows the data from the previous download. And after I click "Update All" in the excel file, the data will be updated. Is there any kind of error proof method to update all data in excel using C #.
c # excel ssis
Phoenix
source share