OleObject Excelapp Excelapp = Create Oleobject
If Excelapp.connecttonewObject ("Excel.Application") <> 0 Then MessageBox ('Ole Error', 'OLE Unable to connect! Please check if your Excel is installed correctly!') Returnend IF
Excelapp.workbooks.addexcelapp.displayalerts = false
Excelapp.activeworkbook.Worksheets [1] .cells (1, 1) .value = "This is the first Sheet" Excelapp.activeworkbook.worksheads [2] .cells (1, 1) .value = "This is the second Sheet "Excelapp.activeworkbook.worksheets [3] .cells (1, 1) .value =" This is the third Sheet "
// Set to different Sheet by specifying parameters 1, 2, 3 in Worksheets [1]
Excelapp.Activeworkbook.saveas ("c: /multisheet.xls", 39) Excelapp.activeworkbook.close () ExceLapp.quit () Excelapp.disconnectObject ()
Destroy Excelapp
Supplement: If you want to add a sheet, you can pass:
ExcelServer.Application.ActiveWorkbook.worksheets.add () // Add a Sheet here