POI does not have the helper methods you want. The simplest way to modify a range formula is using the CellReference object:

        HSSFName name = wb.getName("organisation_name");

        CellReference oldRef = new CellReference(name.getRefersToFormula());

        CellReference newRef = new CellReference(
                oldRef.getSheetName(),
                oldRef.getRow() + 1,
                oldRef.getCol() - 1,
                oldRef.isRowAbsolute(),
                oldRef.isColAbsolute()
        );
        name.setRefersToFormula(newRef.formatAsString());

Yegor

I have this range formula 'General Return Details'!$E$3 got using - HSSFName name = wb.getName("organisation_name");

I want to be able to modify the cell reference bit as easy as possible - so
for example calling a method like String newRef = modifyColumnValue(name.getRefersToFormula(), 1); giving 'General Return Details'!$E$4
or
  String newRef = modifyRowValue(name.getRefersToFormula(), -1);
giving 'General Return Details'!$C$4

Is there a simple way of doing this or do I have to write my own methods?

thanks in advance

harry


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to