gpt4 book ai didi

c# - HRESULT : 0x800A03EC Error while saving Excel file 异常

转载 作者:行者123 更新时间:2023-12-03 00:31:59 28 4
gpt4 key购买 nike

我正在保存按钮点击事件的数据,下面是代码:

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 Error while saving Excel file

最佳答案

检查工作表的单元格索引,从 [1,1] 开始sheet.cells[0,0] 将抛出 com 错误。

关于c# - HRESULT : 0x800A03EC Error while saving Excel file 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15597490/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com