Now provides string formula, reads simple formulas, mmmm formulas

PR:
Obtained from:
Submitted by:
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352511 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew C. Oliver 2002-04-28 02:04:58 +00:00
parent 223e626598
commit 299fcceb90
3 changed files with 23 additions and 2 deletions

View File

@ -157,7 +157,7 @@ public class FormulaRecord
int offset) int offset)
{ {
Stack stack = new Stack(); Stack stack = new Stack();
/*int pos = 22 + offset; int pos = 22 + offset;
while (pos < size) while (pos < size)
{ {
@ -165,7 +165,7 @@ public class FormulaRecord
pos += ptg.getSize(); pos += ptg.getSize();
stack.push(ptg); stack.push(ptg);
}*/ }
return stack; return stack;
} }

View File

@ -391,6 +391,18 @@ end;
} }
} }
/**
* Convience method which takes in a list then passes it to the other toFormulaString
* signature
*/
public static String toFormulaString(List lptgs) {
String retval = null;
Ptg[] ptgs = new Ptg[lptgs.size()];
ptgs = (Ptg[])lptgs.toArray(ptgs);
retval = toFormulaString(ptgs);
return retval;
}
/** Static method to convert an array of Ptgs in RPN order /** Static method to convert an array of Ptgs in RPN order
* to a human readable string format in infix mode * to a human readable string format in infix mode
* TODO - extra brackets might appear, but string will be semantically correct. * TODO - extra brackets might appear, but string will be semantically correct.

View File

@ -712,6 +712,15 @@ public class HSSFCell
} }
} }
public String getCellFormula() {
String retval=null;
retval =
FormulaParser.toFormulaString(((FormulaRecord)record).getParsedExpression());
return retval;
}
/** /**
* get the value of the cell as a number. For strings we throw an exception. * get the value of the cell as a number. For strings we throw an exception.