gpt4 book ai didi

c# - HRESULT 异常 : 0x80010105 (RPC_E_SERVERFAULT) when opening xlsx file

转载 作者:行者123 更新时间:2023-11-30 17:37:49 31 4
gpt4 key购买 nike

我有一个让我发疯的异常。

当我尝试以这种方式打开 .xlsx 文件时

Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();
string v = "path\File.xlsx";
Workbook wb = app.Workbooks.Open(v); //This triggers the exception
app.Visible = true;
Worksheet sh = wb.Sheets[1];

我有这个异常(exception)

Error: System.Runtime.InteropServices.COMException (0x80010105): Server launches an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object
at MainWindow.loadFile(String v) in MainWindow.cs:line 139

谁能给我一个解决方案,为什么会这样?

Ps:我正在使用 Interop 库打开 Excel。

编辑:显然如果我设置app.Visible = true; 它有效,但我不希望出现 Excel 窗口。

最佳答案

 appExcel.Visible = true;
classeur = appExcel.Workbooks.Open(DB_Path, 0, false, 5, "", "", true, XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
appExcel.Visible = false;

关于c# - HRESULT 异常 : 0x80010105 (RPC_E_SERVERFAULT) when opening xlsx file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37391337/

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