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.StartPosition

Surely there has to be an easier way?

Cheers

Answer1:

Seems that Original Poster 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)

<strong>UPDATE</strong> In newer versions of GemBox.Spreadsheet (3.9 and above) the ExcelCell has an additional Name property which returns cell's address.

Answer2:

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.

Answer3:

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

人吐槽 人点赞

Recommend

Comment

用户名: 密码:
验证码: 匿名发表

你可以使用这些语言

查看评论:Gembox - get address of ExcelCell