如何使用 Cell 获取 Cell Reference?

How to get Cell Reference using Cell?

我正在使用 apache poi 3.11,从 CellReference 中,我可以使用以下代码获取 rowIndex 和 Column Index。

CellReference cr = new CellReference("A1");
row = mySheet.getRow(cr.getRow());
cell = row.getCell(cr.getCol());

但是我的 rowIndex 和 columnIndex 是动态生成的,如何使用 rowIndex 和 columnIndex 获取 CellReference?

XSSFRow row = mySheet.getRow(rowIndex); 
XSSFCell cell = row.getCell(columnIndex);

使用 CellReference class 的 CellReference(int pRow, int pCol) 构造函数和所创建实例的 formatAsString 方法创建 CellReference 实例。

您可以按照静态方法并将行号附加到结果列字符串中来获取字符串中的列

ColString= CellReference.convertNumToColString(columnIdex)