Dim uWorkBook As WorkBook = Nothing
Dim sTempFileName As String = "krish.xls"
If uWorkBook Is Nothing Then
If My.Computer.FileSystem.FileExists(sTempFileName) Then
My.Computer.FileSystem.DeleteFile(sTempFileName)
End If
uWorkBook = mExcelExp.Export(mUltraGrid_ONE, sTempFileName)
'THIS WILL EXPORT FIRST GRID TO WORKBOOK OBJECT, IN SHEET1
Else
uWorkBook.Worksheets.Add("Sheet" & uWorkBook.Worksheets.Count + 1)
uWorkBook = mExcelExp.Export(mUltraGrid_TWO, uWorkBook.Worksheets(uWorkBook.Worksheets.Count - 1))
'I WANT SECOND GRID TO BE EXPORTED IN SECOND SHEET2, IN SAME WORKBOOK. And it does too. BUT when Process.Start command runs and opens the tile, it opens the excel file with only one sheet into it, i.e. with the first grid. When you see uWorkBook object in Watch window, you can see two sheets in there.
System.Diagnostics.Process.Start(sTempFileName)
May be I am doine something wrong? !! ?? My company is using this version: 6.0.20063.1091. I don't have any Load or Save method in uWorkBook object. (This is in .Net 2.0 Framework)
Thanks Mike, I'm able to get rid of multiple excel files and able to export all grids in one excel file and different worksheet.
I think you need to do something like this:
Dim wb As New Workbook Dim ws1 As Worksheet = wb.Worksheets.Add("Worksheet 1") Me.UltraGridExcelExporter1.Export(Me.UltraGrid1, ws1) Dim ws2 As Worksheet = wb.Worksheets.Add("Worksheet 2") Me.UltraGridExcelExporter1.Export(Me.UltraGrid2, ws2) BIFF8Writer.WriteWorkbookToFile(wb, fileName)