使用SpreadSheetGear的Advanced Cells API时使用范围名称建立索引 [英] Indexing with range names while using SpreadSheetGear's Advanced Cells API

查看:148
本文介绍了使用SpreadSheetGear的Advanced Cells API时使用范围名称建立索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理包含许多工作表甚至更多公式的Excel文件.我可以使用范围名称来引用所有15K +输入单元格,这比仅仅使用列行索引(如"AE2318")要好得多而且可读性强.

I'm dealing with Excel file containing many sheets and even more formulas. I can reference all the 15K+ input cells with their range names, which is much nicer and readable than just using column-row indexes, like "AE2318".

由于文件很大,所以我想使用SpreadsheetGear.Advanced.Cells界面来利用任何可能的加速方法.但是,我注意到IValues接口可以使用基于0的行和列索引进行索引.

Since the file is huge, I want to use SpreadsheetGear.Advanced.Cells interface to take advantage of any speedup possible. I noticed however that IValues interface can be indexed with 0-based row and column indexes.

如何仍然使用范围名称来引用单元格?

How could I still use range names to refer to cells?

我想到的一件事是构造一个字典,在其中存储哪个范围(具有给定范围名称的单元格)驻留在哪个工作表和哪个行/列上.在Excel中,在Formulas功能区上有Name Manager,其中包含所有这些信息,但是如何使用SpreadSheetGear进行访问呢?该信息可从VBA获得.

One thing I thought is to construct a dictionary, where I would store which ranges (cell with a given range name) resides on which sheet and which row/column. In Excel on the Formulas ribbon there's the Name Manager, which contains all this information, but how can I access that with SpreadSheetGear? The information is available from VBA.

推荐答案

您可以通过以下方式访问命名范围:

You can access Named Ranges via:

  1. IWorkbook.名称 [...],它将包括整个工作簿的所有命名范围.
  2. IWorksheet.名称 [...],其中将包括给定工作表的工作表范围的"命名范围.
  1. IWorkbook.Names[...], which will include all Named Ranges for the entire workbook.
  2. IWorksheet.Names[...], which will include "worksheet-scoped" Named Ranges for a given worksheet.

可以通过foreach循环迭代这些集合,该循环将返回 IName IName 对象,它代表给定的命名范围,并假设它实际上引用了基础IRange(考虑到命名范围也可以引用静态值,例如="Hello World!"),则可以使用IName. www.spreadsheetgear.com/support/help/spreadsheetgear.net.7.0/#SpreadsheetGear2012.Core~SpreadsheetGear.IName~RefersToRange.html"rel =" nofollow> RefersToRange 可以获取该IRange对象以及任何从零开始的对象行/列索引和行/列计数(IRange./ IValues 接口.

These collections can be iterated over via a foreach loop which would return an 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 interface.

这篇关于使用SpreadSheetGear的Advanced Cells API时使用范围名称建立索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆