gpt4 book ai didi

vb.net - 发生 COMException - 未知名称。 (来自 HRESULT : 0x80020006 (DISP_E_UNKNOWNNAME)) when trying to modify an existing excel file 的异常

转载 作者:行者123 更新时间:2023-12-04 21:58:34 26 4
gpt4 key购买 nike

第三行返回 COMException。 oBooks.GetType().Invoke...

Dim oBooks As Microsoft.Office.Interop.Excel.Workbook = Me.fOpenXlsFile(strXLSFile)

Dim ci As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("en-US")
oBooks.GetType().InvokeMember("Add", Reflection.BindingFlags.InvokeMethod, Nothing, oBooks, Nothing, ci)

For i As Int32 = 0 To objLv.Items.Count - 1
oBooks.Styles.Item(i + 1).Interior.Color = objLv.Items(i).BackColor
Next
oBooks.Save()

最佳答案

您正在尝试将工作簿添加到另一个工作簿。您需要将其添加到 Workbooks 集合中。像这样的东西应该工作:

Dim wbs As Excel.Workbooks = oBooks.Application.Workbooks

wbs.GetType().InvokeMember("Add", Reflection.BindingFlags.InvokeMethod, Nothing, wbs, Nothing, ci)

关于vb.net - 发生 COMException - 未知名称。 (来自 HRESULT : 0x80020006 (DISP_E_UNKNOWNNAME)) when trying to modify an existing excel file 的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39201021/

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