adam2510
adam2510

Reputation: 563

Apache POI Cell and Row retrieved via CellReference is Null

UPDATE: I've decided to change to Apache POI and all seems to be going well except I am unable to retreive the cell yet it can pick up the row.

        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());
        }  

I can confirm that it is not retrieving the row as I have stepped through the program and it will hit the if statement then skip over it.


Older post deleted

Upvotes: 1

Views: 1249

Answers (1)

adam2510
adam2510

Reputation: 563

I did a bit more googling on the issue this morning and I came across what has been staring me in the face all the time...

Basically I needed to use the Name interface

        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());
        }    

Upvotes: 2

Related Questions