通过CellReference检索的Apache POI Cell和Row是Null

时间:2013-08-24 16:35:01

标签: java apache-poi jxl

更新:我已决定更改为Apache POI,但似乎一切顺利,但我无法检索该单元格但它可以接收该行。

        CellReference ref = new CellReference("personal_business_name");
        Row r = sheet.getRow(ref.getRow());
        Cell c;
        if (r != null) {
        c = r.getCell(ref.getCol());
        c.setCellValue(buyers.get(transactions.get(transactionNo-1).getBuyerId()-1).getSurname_organization() + ", " + buyers.get(transactions.get(transactionNo-1).getBuyerId()-1).getFirstname());
        }  

我可以确认它没有检索到该行,因为我已经完成了程序,它会点击if语句然后跳过它。


旧帖子已删除

1 个答案:

答案 0 :(得分:2)

今天早上我在这个问题上进行了一些谷歌搜索,我偶然发现了一直盯着我看的......

基本上我需要使用Name界面

        Name name = template.getName("personal_business_name");
        AreaReference aref = new AreaReference(name.getRefersToFormula());
        CellReference ref = aref.getFirstCell();
        Row r = sheet.getRow(ref.getRow());
        Cell c;
        if (r != null) {
        c = r.getCell(ref.getCol());
        c.setCellValue(buyers.get(transactions.get(transactionNo-1).getBuyerId()-1).getSurname_organization() + ", " + buyers.get(transactions.get(transactionNo-1).getBuyerId()-1).getFirstname());
        }