P
Peter Karlström
Hi
I'm working in a VB.NET project in VS 2008 where a WebService is to create a
customized Excel 2007 spreadsheet.
The WebService recieves a tab-separated CSV file and returns a complete and
formatted Excel 2007 xlsx workbook.
Everything works fine except for the Excel-process which I start.
It won't quit no matter what I do.
This is the code:
Public Function CreateReport(ByVal CSVFile As String) As String
Dim xlApp As Microsoft.Office.Interop.Excel.Application
Dim xlDoc As Workbook
Try
xlApp = New Microsoft.Office.Interop.Excel.Application
File.Delete("C:\Temp\tempfile.xlsx")
Catch ex As Exception
CreateReport = ""
Exit Function
End Try
Try
xlApp.DisplayAlerts = False
xlDoc = xlApp.Workbooks.Open(CSVFile)
ImportCSV(xlApp, CSVFile)
xlDoc.SaveAs(Filename:="C:\Temp\tempfile.xlsx",
FileFormat:=XlFileFormat.xlOpenXMLWorkbook, CreateBackup:=False)
xlDoc.Close()
xlApp.Quit()
CreateReport = "c:\Temp\Tempfile.xlsx"
Try
File.Delete(CSVFile)
Catch ex As Exception
End Try
Catch ex As Exception
System.Diagnostics.Debug.Print(ex.Message)
CreateReport = ""
xlApp.Quit()
End Try
Try
xlApp.Quit()
xlApp = Nothing
Catch ex As Exception
System.Diagnostics.Debug.Print(ex.Message)
End Try
Return CreateReport
End Function
The ImportCSV sub is only formatting data, and even id I omit to call it,
the Excel process still runs when I'm done.
Anybody have a clue?
Thanks in advance
I'm working in a VB.NET project in VS 2008 where a WebService is to create a
customized Excel 2007 spreadsheet.
The WebService recieves a tab-separated CSV file and returns a complete and
formatted Excel 2007 xlsx workbook.
Everything works fine except for the Excel-process which I start.
It won't quit no matter what I do.
This is the code:
Public Function CreateReport(ByVal CSVFile As String) As String
Dim xlApp As Microsoft.Office.Interop.Excel.Application
Dim xlDoc As Workbook
Try
xlApp = New Microsoft.Office.Interop.Excel.Application
File.Delete("C:\Temp\tempfile.xlsx")
Catch ex As Exception
CreateReport = ""
Exit Function
End Try
Try
xlApp.DisplayAlerts = False
xlDoc = xlApp.Workbooks.Open(CSVFile)
ImportCSV(xlApp, CSVFile)
xlDoc.SaveAs(Filename:="C:\Temp\tempfile.xlsx",
FileFormat:=XlFileFormat.xlOpenXMLWorkbook, CreateBackup:=False)
xlDoc.Close()
xlApp.Quit()
CreateReport = "c:\Temp\Tempfile.xlsx"
Try
File.Delete(CSVFile)
Catch ex As Exception
End Try
Catch ex As Exception
System.Diagnostics.Debug.Print(ex.Message)
CreateReport = ""
xlApp.Quit()
End Try
Try
xlApp.Quit()
xlApp = Nothing
Catch ex As Exception
System.Diagnostics.Debug.Print(ex.Message)
End Try
Return CreateReport
End Function
The ImportCSV sub is only formatting data, and even id I omit to call it,
the Excel process still runs when I'm done.
Anybody have a clue?
Thanks in advance