开发者

Gembox - get address of ExcelCell

We are evaluating Gembox as a replacement for Aspose. I think I am going blind as one thing I cannot do is easily get the address (e.g. "B4") of an ExcelCell.

For example, when iterating through the cells, we may encounter an unexpected value and would like to tell the user where the error is.

var dodgyCell = sheet.Cells[rowIndex, colIndex];

The best workaround I have found if to create a CellRange of one cell and then use the startposition. i.e.:

var cr = sheet.Cells.GetSubrangeAbsolute(rowIndex, colIndex, rowIndex, colIndex);
var message = "Dodgy value was found in cell " + cr.S开发者_开发知识库tartPosition

Surely there has to be an easier way?

Cheers


EDIT 2016-01-30:
In newer versions of GemBox.Spreadsheet (3.9 and above) the ExcelCell has an additional Name property which returns cell's address.

ORIGINAL ANSWER:
Seems that OP has figured out the answer. Unfortunately it is not well visible so here it is again:
To convert row and column index to position string ("A1", "BN27", etc.) use static method CellRange.RowColumnToPosition(int row, int column)


I know you've had the answer you are looking for but since someone else recommended a commercial product, I encourage you to look at epplus which is free, and coincidentally, I happened to have used today for the first time. It has many advanced features and a very simple and intuitive API.


According to the Gembox documentation, there is a "CellRange.ToString Method" that 'Returns a String that represents the current CellRange.' You might want to try that.

Reference: http://www.gemboxsoftware.com/Spreadsheet/Help/index.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜