java - 如何从工作簿之一中读取不唯一的命名范围
问题描述
如何从工作簿中的一张工作表中读取命名范围。命名范围存在于具有相同名称的多个工作簿工作表中。
我尝试将工作簿作为一个整体,无法在工作表级别设置范围
String cname = "TestName";
Workbook wb = getMyWorkbook(); // retrieve workbook
// retrieve the named range
int namedCellIdx = wb.getNameIndex(cellName);
Name aNamedCell = wb.getNameAt(namedCellIdx);
// retrieve the cell at the named range and test its contents
AreaReference aref = new AreaReference(aNamedCell.getRefersToFormula());
CellReference[] crefs = aref.getAllReferencedCells();
for (int i=0; i<crefs.length; i++) {
Sheet s = wb.getSheet(crefs[i].getSheetName());
Row r = sheet.getRow(crefs[i].getRow());
Cell c = r.getCell(crefs[i].getCol());
// extract the cell contents based on cell type etc.
}
解决方案
推荐阅读
- reactjs - 反冲原子打字稿默认未定义
- javascript - 从 Promise 中获取数据
- javascript - ReactJS / Material-UI / Javascript:无法在 TableRow 上获得圆角边框
- python - 使用 Beautiful Soup 提取特定列表
- reactjs - 如何通过在react js中单击来删除特定元素
- python - python - 如何使用openpyxl库使用python将列从一个excel表复制到另一个?
- android - 从 ADB 发送意图到运行时注册的 BroadcastReceiver
- .net - 按钮在 .NET Web 窗体上启用后不执行任何操作
- arrays - Julia 条件赋值基于 | (或)在多维数组中
- python-3.x - 无法在 Windows 10 中使用 pycharms 通过 pip install uwsgi 安装 uwsgi