private _workbook _workbook = null;
private worksheet _worksheet = null;
private excel.application _excelapplicatin = null;_excelapplicatin = new excel.application();
_excelapplicatin.visible = true;
_excelapplicatin.displayalerts = true;_workbook = _excelapplicatin.workbooks.add(xlsheettype.xlworksheet);
_worksheet = (worksheet)_workbook.activesheet;
_worksheet.name = "worksheetname";//打开已存在的excel
string strexcelpathname = appdomain.currentdomain.basedirectory + "excelsheetname.xls";
excel.workbook workbook = application.workbooks.open(strexcelpathname, type.missing, type.missing,
type.missing, type.missing, type.missing, type.missing, type.missing,
type.missing, type.missing, type.missing, type.missing, type.missing);
//读取已打开的excel
excel.worksheet worksheet1 = (excel.worksheet)workbook.sheets["sheetname1"];
excel.worksheet worksheet2 = (excel.worksheet)workbook.sheets["sheetname2"];//添加一个worksheet
worksheet worksheet = (worksheet)workbook.worksheets.add(system.type.missing, system.type.missing, system.type.missing, system.type.missing);
首页 1 2 末页