来自HRESULT的异常:0x800A03EC保存Excel文件时出错 [英] Exception from HRESULT: 0x800A03EC Error while saving Excel file
本文介绍了来自HRESULT的异常:0x800A03EC保存Excel文件时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在保存按钮的click事件上的数据,下面是代码:
I am saving data on button's click event and below is code:
using Excel = Microsoft.Office.Interop.Excel;
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
Excel.Range range;
object misValue = System.Reflection.Missing.Value;
String st = System.IO.Directory.GetCurrentDirectory() + "\\A.xlsx";
xlApp = new Excel.ApplicationClass();
xlWorkBook = xlApp.Workbooks.Open(st, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
int i = 6;
for (i = 6; i < 10; i++)
{
xlWorkBook.SaveAs(st, XlFileFormat.xlExcel9795, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlShared, misValue, misValue, misValue, misValue, misValue);
MessageBox.Show(xlWorkSheet.get_Range("L" + @i, "L" + @i).Value2.ToString());
}
xlWorkBook.Close(true, misValue, misValue);
xlApp.Quit();
保存时,它给我错误:
HRESULT:0x800A03EC保存Excel文件时出错
HRESULT: 0x800A03EC Error while saving Excel file
推荐答案
检查工作表的单元格索引,从[1,1]开始 sheet.cells [0,0]将引发com错误.
check for cell indices for sheet , starts from [1,1] sheet.cells[0,0] will throw com error.
这篇关于来自HRESULT的异常:0x800A03EC保存Excel文件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文