在导出Excel时,如何添加多个Worksheets对象??保存Excel文件时出错??
同上,同时还在保存Excel文件时出现错误。try
{
wkb.SaveAs(excelFilePath, objOpt, objOpt, objOpt, objOpt, objOpt, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, objOpt, objOpt, objOpt, objOpt, objOpt);//抛出 InvaildCastException 异常
// 在构造函数中初始化对象如下
// objOpt = Missing.Value;
// wkb = this.excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
}
finally
{
wkb.Close(false, objOpt, objOpt);
} --------------------编程问答-------------------- Excel.Worksheet sheet = (Excel.Worksheet)workbook.Worksheets[2];
workbook.Sheets.Add(sheet,objMissing,1,objMissing)来添加worksheet.
我是用这个保存的。
workbook.Close(true, path , objMissing); --------------------编程问答--------------------
补充:.NET技术 , C#