diff --git a/src/java/org/apache/poi/ss/formula/ptg/RefNPtg.java b/src/java/org/apache/poi/ss/formula/ptg/RefNPtg.java index 715836f8d6..90d43ca945 100644 --- a/src/java/org/apache/poi/ss/formula/ptg/RefNPtg.java +++ b/src/java/org/apache/poi/ss/formula/ptg/RefNPtg.java @@ -17,6 +17,7 @@ package org.apache.poi.ss.formula.ptg; +import org.apache.poi.ss.util.CellReference; import org.apache.poi.util.LittleEndianInput; /** @@ -33,4 +34,23 @@ public final class RefNPtg extends Ref2DPtgBase { protected byte getSid() { return sid; } + + protected final String formatReferenceAsString() { + StringBuilder builder = new StringBuilder(); + + // The bits in RefNPtg indicate offset, not relative/absolute values! + if(isRowRelative()) { + builder.append("RowOffset: ").append(getRow()).append(" "); + } else { + builder.append(getRow()+1); + } + + if(isColRelative()) { + builder.append(" ColOffset: ").append(getColumn()); + } else { + builder.append(CellReference.convertNumToColString(getColumn())); + } + + return builder.toString(); + } } diff --git a/src/java/org/apache/poi/ss/formula/ptg/RefPtgBase.java b/src/java/org/apache/poi/ss/formula/ptg/RefPtgBase.java index 5ff9a7a3ca..6d63ed5a46 100644 --- a/src/java/org/apache/poi/ss/formula/ptg/RefPtgBase.java +++ b/src/java/org/apache/poi/ss/formula/ptg/RefPtgBase.java @@ -105,7 +105,7 @@ public abstract class RefPtgBase extends OperandPtg { return column.getValue(field_2_col); } - protected final String formatReferenceAsString() { + protected String formatReferenceAsString() { // Only make cell references as needed. Memory is an issue CellReference cr = new CellReference(getRow(), getColumn(), !isRowRelative(), !isColRelative()); return cr.formatAsString();