使用 SpreadSheetGear 的高级单元格时使用范围名称进行索引 API
Indexing with range names while using SpreadSheetGear's Advanced Cells API
我正在处理包含许多 sheet 甚至更多公式的 Excel 文件。我可以引用所有 15K+ 输入单元格及其范围名称,这比仅使用列行索引(如 "AE2318"
.
更好且可读性更好
由于文件很大,我想使用 SpreadsheetGear.Advanced.Cells
接口来利用任何可能的加速。但是我注意到 IValues
接口可以使用基于 0 的行和列索引进行索引。
我怎么还能使用范围名称来引用单元格?
我想的一件事是构建一个字典,我将在其中存储哪些范围(具有给定范围名称的单元格)位于哪个 sheet 和哪个 row/column 上。在 Formulas
功能区的 Excel 中有 Name Manager
,其中包含所有这些信息,但我如何使用 SpreadSheetGear
访问它?该信息可从 VBA.
获得
您可以通过以下方式访问命名范围:
这些集合可以通过 foreach
循环迭代,这将 return 一个 IName object for each Named Range. You can also index into these collections via the Named Range's (string) name, or index within the collection. Once you have an IName object that represents a given Named Range, and assuming it actually refers to an underlying IRange (consider that Named Ranges could also refer to static values such as ="Hello World!"
), you can use IName.RefersToRange to get that IRange object and any zero-based row/column indexes and row/column counts (IRange.Row/Column and RowCount/ColumnCount) for use in the "high performance" IValues 接口。
我正在处理包含许多 sheet 甚至更多公式的 Excel 文件。我可以引用所有 15K+ 输入单元格及其范围名称,这比仅使用列行索引(如 "AE2318"
.
由于文件很大,我想使用 SpreadsheetGear.Advanced.Cells
接口来利用任何可能的加速。但是我注意到 IValues
接口可以使用基于 0 的行和列索引进行索引。
我怎么还能使用范围名称来引用单元格?
我想的一件事是构建一个字典,我将在其中存储哪些范围(具有给定范围名称的单元格)位于哪个 sheet 和哪个 row/column 上。在 Formulas
功能区的 Excel 中有 Name Manager
,其中包含所有这些信息,但我如何使用 SpreadSheetGear
访问它?该信息可从 VBA.
您可以通过以下方式访问命名范围:
这些集合可以通过 foreach
循环迭代,这将 return 一个 IName object for each Named Range. You can also index into these collections via the Named Range's (string) name, or index within the collection. Once you have an IName object that represents a given Named Range, and assuming it actually refers to an underlying IRange (consider that Named Ranges could also refer to static values such as ="Hello World!"
), you can use IName.RefersToRange to get that IRange object and any zero-based row/column indexes and row/column counts (IRange.Row/Column and RowCount/ColumnCount) for use in the "high performance" IValues 接口。