S
Satish Itty
Hi all,
I using excel automation to generate some reports in excel. I guess I'm
not doing it correctly because Every time the report is run it leaves a
Excel.exe process open in the system.process even after the user closes
the excel file generated.
Here is the code block I'm using
Dim oExcelApp As Excel.Application
Dim oExcel As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim rownum As Integer = 7
oExcelApp = CreateObject("Excel.Application")
oExcel = oExcelApp.Workbooks.Add(Application.StartupPath + \xxxx.xlt")
oSheet = oExcel.ActiveSheet
oExcelApp.Visible = False
oSheet.Range("A4").Value = String.Format("As of {0:G}", DateTime.Now())
For Each row As DataRow In ds.Tables(0).Rows
oSheet.Rows(rownum + 1).EntireRow.Select()
oExcelApp.Selection.Insert(Excel.XlInsertShiftDirection.xlShiftDown)
oSheet.Range(String.Format("A{0}:V{0}", rownum)).Value = row.ItemArray
rownum += 1
Next
oExcelApp.Visible = True
oSheet = Nothing
oExcel = Nothing
oExcelApp = Nothing
Any ideas as to whats worng here?
Thanks,
Satish.
I using excel automation to generate some reports in excel. I guess I'm
not doing it correctly because Every time the report is run it leaves a
Excel.exe process open in the system.process even after the user closes
the excel file generated.
Here is the code block I'm using
Dim oExcelApp As Excel.Application
Dim oExcel As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim rownum As Integer = 7
oExcelApp = CreateObject("Excel.Application")
oExcel = oExcelApp.Workbooks.Add(Application.StartupPath + \xxxx.xlt")
oSheet = oExcel.ActiveSheet
oExcelApp.Visible = False
oSheet.Range("A4").Value = String.Format("As of {0:G}", DateTime.Now())
For Each row As DataRow In ds.Tables(0).Rows
oSheet.Rows(rownum + 1).EntireRow.Select()
oExcelApp.Selection.Insert(Excel.XlInsertShiftDirection.xlShiftDown)
oSheet.Range(String.Format("A{0}:V{0}", rownum)).Value = row.ItemArray
rownum += 1
Next
oExcelApp.Visible = True
oSheet = Nothing
oExcel = Nothing
oExcelApp = Nothing
Any ideas as to whats worng here?
Thanks,
Satish.