我现在要用asp.net(C#)删除Excel文件中的某个行,哪位高手帮忙回复,要完整代码。谢谢!
Excel.Application excelApp = null;
Excel.Workbook book = null;
Excel.Worksheet sheet = null;
Excel.Range range = null;
excelApp = new Microsoft.Office.Interop.Excel.Application();
excelApp.Visible = false;
book = excelApp.Workbooks.Open(filepath, Missing.Value, false, Missing.Value, Missing.Value, Missing.Value, true,Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value);
sheet = (Excel.Worksheet)book.Sheets.get_Item(sheet_num);
range = (Excel.Range)sheet.Rows[delete_num, Missing.Value];
range.EntireRow.Delete(Excel.XlDeleteShiftDirection.xlShiftUp);
book.Save();
book.Close(Missing.Value, Missing.Value, Missing.Value);
excelApp.Workbooks.Close();
excelApp.Quit();
出现异常:检索 COM 类工厂中 CLSID 为 {00024500-0000-0000-C000-000000000046} 的组件时失败,原因是出现以下错误: 80070005。
哪位高手知道,帮忙解决下,谢谢!