Infragistics Excel 导入加载选项

Infragistics Excel Import Loadoptions

通过 Infragistics 组件加载 Excel-Sheets 的加载方法出现两个错误。

第一个:

这是因为 Excel-工作簿已损坏。但是如何在不验证其是否损坏的情况下加载工作簿?

第二个:

这是因为工作表中有超链接。如何在加载前删除它们?

我的代码:

'stuff...
Dim file as String = "test.xls"
xls = New Workbook()
xls = Workbook.Load(file)
'stuff...

Infragistics 的页面不是很有帮助:http://help.infragistics.com/Help/Doc/WinForms/2012.2/CLR4.0/html/Infragistics4.Documents.Excel.v12.2~Infragistics.Documents.Excel.Workbook~Load(Stream).html

我认为您可能将此方法用于错误的目的,我没有使用 'Infragistics' 的经验,但是查看 link 您提供的这看起来像是一种打开网页的方法基于流作为工作簿对象。

您收到的错误消息是说它无法读取您调用 Workbook.Load 时使用的 file 参数。我的猜测是,此方法需要一个 URL(例如 www.whosebug.com),而您提供的是 'test.xls'

根据您提供的代码,您似乎只是想打开自己机器上的工作簿,为此您可以使用 Workbooks.Open 方法,例如:

xls = Workbook.Open(ThisWorkbook.path & "\test.xls")

这将从与包含宏的文件相同的文件夹中打开名为 "test.xls" 的工作簿,并将其分配给 xls

我认为第一个问题的答案是您无法加载损坏的工作簿,因为 Excel 引擎无法理解该文件。如果您在 Excel 中打开文件,它可能能够修复它,然后您可能能够使用 excel 引擎打开它。

我相信 Infragistics Excel 引擎支持超链接,您应该向 Infragistics 提供有效 excel 文件的示例,该文件由于文件中的超链接而出现加载问题调查一下。

好的伙计们,谢谢您的回复!答案如下:

第一个问题是:

  • 指定的流或文件不包含有效的工作簿。参数名:文件名

Answer:

  • There is no Option to Load a corrupt Workbook into your App without validating the Workbook or something like this. You need to handle this Errormessage and the User must choose another, valid File!

第二个问题是:

  • 无效的 URI:无法解析主机名

Answer:

  • There were mailto-Links in the Worksheets. Normally this is not a Problem for Infragistics. But the mailto Links were broken like this:

    mailto:eric@ domain.com</pre>

  • You see: A space bar in that mailto-Link - so the Link is corrupt. The Invalid Uri came up because of this.