Made Formula Record cough up some info useful for debugging, made functions

get written, but they crash excel right now.  Areas seem to basically work.
I need to investigate further, at first glance, our xls looks the same as
Excel's.  Have to find out what its doing to make it crash like that.
PR:
Obtained from:
Submitted by:
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352551 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew C. Oliver 2002-04-29 01:25:28 +00:00
parent bca318f1fc
commit 263d320010
4 changed files with 71 additions and 5 deletions

View File

@ -365,6 +365,9 @@ public class FormulaRecord
}
return getRecordSize();
}
public int getRecordSize()
{
@ -504,4 +507,43 @@ public class FormulaRecord
}
return false;
}
public String toString()
{
StringBuffer buffer = new StringBuffer();
if (EXPERIMENTAL_FORMULA_SUPPORT_ENABLED) {
buffer.append("[FORMULA]\n");
buffer.append(" .row = ")
.append(Integer.toHexString(getRow())).append("\n");
buffer.append(" .column = ")
.append(Integer.toHexString(getColumn()))
.append("\n");
buffer.append(" .xf = ")
.append(Integer.toHexString(getXFIndex())).append("\n");
buffer.append(" .value = ").append(getValue())
.append("\n");
buffer.append(" .options = ").append(getOptions())
.append("\n");
buffer.append(" .zero = ").append(field_6_zero)
.append("\n");
buffer.append(" .expressionlength= ").append(getExpressionLength())
.append("\n");
buffer.append(" .numptgsinarray = ").append(field_8_parsed_expr.size())
.append("\n");
for (int k = 0; k < field_8_parsed_expr.size(); k++ ) {
buffer.append("formula ").append(k).append(" ")
.append(((Ptg)field_8_parsed_expr.get(k)).toFormulaString());
}
buffer.append("[/FORMULA]\n");
} else {
buffer.append(super.toString());
}
return buffer.toString();
}
}

View File

@ -16,7 +16,7 @@ import java.util.List;
*/
public class FunctionPtg extends OperationPtg {
public final static short sid = 0x22;
private final static int SIZE = 2;
private final static int SIZE = 3;
private byte field_1_num_args;
private byte field_2_fnc_index;
@ -27,6 +27,14 @@ public class FunctionPtg extends OperationPtg {
public FunctionPtg() {
}
public FunctionPtg(byte[] data, int offset) {
offset++;
field_1_num_args = data[ offset + 0 ];
field_2_fnc_index = data[offset + 1 ];
}
public FunctionPtg(String pName, byte pNumOperands) {
field_1_num_args = pNumOperands;
field_2_fnc_index = lookupIndex(pName);
@ -79,8 +87,9 @@ public class FunctionPtg extends OperationPtg {
public void writeBytes(byte[] array, int offset) {
array[offset]=field_1_num_args;
array[offset]=field_2_fnc_index;
array[offset+0]=sid;
array[offset+1]=field_1_num_args;
array[offset+2]=field_2_fnc_index;
}
public int getSize() {

View File

@ -166,6 +166,10 @@ public abstract class Ptg
final int arrayRef = ReferencePtg.sid + 0x40; // excel doesn't really care which one you
// write.
final int valueFunc = FunctionPtg.sid + 0x20; //note this only matters for READ
final int arrayFunc = FunctionPtg.sid + 0x40; // excel doesn't really care which one you
// write.
switch (id)
{
@ -227,9 +231,18 @@ public abstract class Ptg
retval = new ParenthesisPtg(data, offset);
break;
case ValueVariableFunctionPtg.sid :
retval = new ValueVariableFunctionPtg(data, offset);
case FunctionPtg.sid :
retval = new FunctionPtg(data, offset);
break;
/* case valueFunc :
retval = new FunctionPtg(data, offset);
break;
case arrayFunc :
retval = new FunctionPtg(data, offset);
break;
*/
case NamePtg.sid :
retval = new NamePtg(data, offset);

View File

@ -58,6 +58,8 @@ package org.apache.poi.hssf.util;
/**
* Title: Range Address <P>
* Description: provides connectivity utilities for ranges<P>
*
*
* REFERENCE: <P>
* @author IgOr KaTz && EuGeNe BuMaGiN (Tal Moshaiov) (VistaPortal LDT.)
* @version 1.0