diff --git a/src/java/org/apache/poi/hssf/record/formula/FormulaParser.java b/src/java/org/apache/poi/hssf/record/formula/FormulaParser.java index 6fd242cafc..6498ae9ee3 100644 --- a/src/java/org/apache/poi/hssf/record/formula/FormulaParser.java +++ b/src/java/org/apache/poi/hssf/record/formula/FormulaParser.java @@ -70,7 +70,7 @@ import java.io.File; * Lets Build a Compiler, by Jack Crenshaw * BNF for the formula expression is : * ::= [ ]* - * ::= [ ::= [ ]* * ::= | () | | * ::= ([expression [, expression]*]) * @@ -281,8 +281,13 @@ public class FormulaParser { numArgs++; Expression(); } - while (Look == ',') { //TODO handle EmptyArgs - Match(','); + while (Look == ',' || Look == ';') { //TODO handle EmptyArgs + if(Look == ',') { + Match(','); + } + else { + Match(';'); + } Expression(); numArgs++; } @@ -454,15 +459,19 @@ end; String[] operands; for (int i=0;i 0) { + o = (OperationPtg) ptgs[i]; + numOperands = o.getNumberOfOperands(); + operands = new String[numOperands]; + for (int j=0;j. + */ + +package org.apache.poi.hssf.record.formula; + +import org.apache.poi.util.LittleEndian; + +/** + * Number + * Stores a String value in a formula value stored in the format char[] + * @author Werner Froidevaux + */ + +public class StringPtg + extends Ptg +{ + public final static int SIZE = 9; + public final static byte sid = 0x17; + private String field_1_value; + + + /** Create a StringPtg from a byte array read from disk */ + public StringPtg(byte [] data, int offset) + { + setValue(new String(data, offset+3, data[offset+1] + 256*data[offset+2])); + } + + /** Create a StringPtg from a string representation of the number + * Number format is not checked, it is expected to be validated in the parser + * that calls this method. + * @param value : String representation of a floating point number + */ + protected StringPtg(String value) { + setValue(value); + } + + + public void setValue(String value) + { + field_1_value = value; + } + + + public String getValue() + { + return field_1_value; + } + + public void writeBytes(byte [] array, int offset) + { + array[ offset + 0 ] = sid; + array[ offset + 1 ] = (byte)(getValue().length() % 256); + array[ offset + 2 ] = (byte)(getValue().length() / 256); + System.arraycopy(getValue().getBytes(), 0, array, offset + 3, getValue().length()); + } + + public int getSize() + { + return field_1_value.length() + 3; + } + + public String toFormulaString() + { + return getValue(); + } + +} +