In the ooxml branch, convert the formula stuff from using hssf.HSSFWorkbook to ss.Workbook, so that everything now works for XSSF too
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@648454 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
101e30ed37
commit
d578c64812
@ -27,7 +27,7 @@ import java.util.regex.Pattern;
|
|||||||
import org.apache.poi.hssf.record.formula.*;
|
import org.apache.poi.hssf.record.formula.*;
|
||||||
import org.apache.poi.hssf.record.formula.function.FunctionMetadata;
|
import org.apache.poi.hssf.record.formula.function.FunctionMetadata;
|
||||||
import org.apache.poi.hssf.record.formula.function.FunctionMetadataRegistry;
|
import org.apache.poi.hssf.record.formula.function.FunctionMetadataRegistry;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class parses a formula string into a List of tokens in RPN order.
|
* This class parses a formula string into a List of tokens in RPN order.
|
||||||
@ -87,7 +87,7 @@ public final class FormulaParser {
|
|||||||
*/
|
*/
|
||||||
private char look;
|
private char look;
|
||||||
|
|
||||||
private HSSFWorkbook book;
|
private Workbook book;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,14 +102,14 @@ public final class FormulaParser {
|
|||||||
* model.Workbook, then use the convenience method on
|
* model.Workbook, then use the convenience method on
|
||||||
* usermodel.HSSFFormulaEvaluator
|
* usermodel.HSSFFormulaEvaluator
|
||||||
*/
|
*/
|
||||||
public FormulaParser(String formula, HSSFWorkbook book){
|
public FormulaParser(String formula, Workbook book){
|
||||||
formulaString = formula;
|
formulaString = formula;
|
||||||
pointer=0;
|
pointer=0;
|
||||||
this.book = book;
|
this.book = book;
|
||||||
formulaLength = formulaString.length();
|
formulaLength = formulaString.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Ptg[] parse(String formula, HSSFWorkbook book) {
|
public static Ptg[] parse(String formula, Workbook book) {
|
||||||
FormulaParser fp = new FormulaParser(formula, book);
|
FormulaParser fp = new FormulaParser(formula, book);
|
||||||
fp.parse();
|
fp.parse();
|
||||||
return fp.getRPNPtg();
|
return fp.getRPNPtg();
|
||||||
@ -252,7 +252,7 @@ public final class FormulaParser {
|
|||||||
Match('!');
|
Match('!');
|
||||||
String sheetName = name;
|
String sheetName = name;
|
||||||
String first = GetName();
|
String first = GetName();
|
||||||
short externIdx = book.getExternalSheetIndex(book.getSheetIndex(sheetName));
|
short externIdx = (short)book.getExternalSheetIndex(book.getSheetIndex(sheetName));
|
||||||
if (look == ':') {
|
if (look == ':') {
|
||||||
Match(':');
|
Match(':');
|
||||||
String second=GetName();
|
String second=GetName();
|
||||||
@ -927,7 +927,7 @@ end;
|
|||||||
* @param lptgs list of Ptg, can be null or empty
|
* @param lptgs list of Ptg, can be null or empty
|
||||||
* @return a human readable String
|
* @return a human readable String
|
||||||
*/
|
*/
|
||||||
public static String toFormulaString(HSSFWorkbook book, List lptgs) {
|
public static String toFormulaString(Workbook book, List lptgs) {
|
||||||
String retval = null;
|
String retval = null;
|
||||||
if (lptgs == null || lptgs.size() == 0) return "#NAME";
|
if (lptgs == null || lptgs.size() == 0) return "#NAME";
|
||||||
Ptg[] ptgs = new Ptg[lptgs.size()];
|
Ptg[] ptgs = new Ptg[lptgs.size()];
|
||||||
@ -953,7 +953,7 @@ end;
|
|||||||
* @param ptgs array of Ptg, can be null or empty
|
* @param ptgs array of Ptg, can be null or empty
|
||||||
* @return a human readable String
|
* @return a human readable String
|
||||||
*/
|
*/
|
||||||
public static String toFormulaString(HSSFWorkbook book, Ptg[] ptgs) {
|
public static String toFormulaString(Workbook book, Ptg[] ptgs) {
|
||||||
if (ptgs == null || ptgs.length == 0) {
|
if (ptgs == null || ptgs.length == 0) {
|
||||||
// TODO - what is the justification for returning "#NAME" (which is not "#NAME?", btw)
|
// TODO - what is the justification for returning "#NAME" (which is not "#NAME?", btw)
|
||||||
return "#NAME";
|
return "#NAME";
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.formula.function.FunctionMetadata;
|
import org.apache.poi.hssf.record.formula.function.FunctionMetadata;
|
||||||
import org.apache.poi.hssf.record.formula.function.FunctionMetadataRegistry;
|
import org.apache.poi.hssf.record.formula.function.FunctionMetadataRegistry;
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ public abstract class AbstractFunctionPtg extends OperationPtg {
|
|||||||
return field_2_fnc_index == FUNCTION_INDEX_EXTERNAL;
|
return field_2_fnc_index == FUNCTION_INDEX_EXTERNAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book) {
|
public String toFormulaString(Workbook book) {
|
||||||
return getName();
|
return getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,7 +75,7 @@ public class AddPtg
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Implementation of method from Ptg */
|
/** Implementation of method from Ptg */
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return "+";
|
return "+";
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
import org.apache.poi.hssf.util.AreaReference;
|
import org.apache.poi.hssf.util.AreaReference;
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.hssf.util.CellReference;
|
||||||
@ -273,7 +273,7 @@ public class Area3DPtg extends Ptg implements AreaI
|
|||||||
* @return text representation of this area reference that can be used in text
|
* @return text representation of this area reference that can be used in text
|
||||||
* formulas. The sheet name will get properly delimited if required.
|
* formulas. The sheet name will get properly delimited if required.
|
||||||
*/
|
*/
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
// First do the sheet name
|
// First do the sheet name
|
||||||
StringBuffer retval = new StringBuffer();
|
StringBuffer retval = new StringBuffer();
|
||||||
|
@ -29,7 +29,7 @@ import org.apache.poi.util.BitField;
|
|||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
import org.apache.poi.hssf.util.AreaReference;
|
import org.apache.poi.hssf.util.AreaReference;
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.hssf.util.CellReference;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies a rectangular area of cells A1:A4 for instance.
|
* Specifies a rectangular area of cells A1:A4 for instance.
|
||||||
|
@ -20,7 +20,7 @@ package org.apache.poi.hssf.record.formula;
|
|||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
import org.apache.poi.util.BitField;
|
import org.apache.poi.util.BitField;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,7 +66,7 @@ public class AreaErrPtg extends AreaPtg
|
|||||||
array[offset] = (byte) (sid + ptgClass);
|
array[offset] = (byte) (sid + ptgClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return "#REF!";
|
return "#REF!";
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import org.apache.poi.util.BitField;
|
|||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
import org.apache.poi.hssf.util.AreaReference;
|
import org.apache.poi.hssf.util.AreaReference;
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.hssf.util.CellReference;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies a rectangular area of cells A1:A4 for instance.
|
* Specifies a rectangular area of cells A1:A4 for instance.
|
||||||
@ -58,7 +58,7 @@ public class AreaNAPtg
|
|||||||
return "AreaNAPtg";
|
return "AreaNAPtg";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
|
throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import org.apache.poi.util.BitField;
|
|||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
import org.apache.poi.hssf.util.AreaReference;
|
import org.apache.poi.hssf.util.AreaReference;
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.hssf.util.CellReference;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies a rectangular area of cells A1:A4 for instance.
|
* Specifies a rectangular area of cells A1:A4 for instance.
|
||||||
@ -61,7 +61,7 @@ public class AreaNPtg
|
|||||||
return "AreaNPtg";
|
return "AreaNPtg";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
|
throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import org.apache.poi.util.BitField;
|
|||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
import org.apache.poi.hssf.util.AreaReference;
|
import org.apache.poi.hssf.util.AreaReference;
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.hssf.util.CellReference;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies a rectangular area of cells A1:A4 for instance.
|
* Specifies a rectangular area of cells A1:A4 for instance.
|
||||||
@ -59,7 +59,7 @@ public class AreaNVPtg
|
|||||||
return "AreaNVPtg";
|
return "AreaNVPtg";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
|
throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ import org.apache.poi.util.BitFieldFactory;
|
|||||||
|
|
||||||
import org.apache.poi.hssf.util.AreaReference;
|
import org.apache.poi.hssf.util.AreaReference;
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.hssf.util.CellReference;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -303,11 +303,11 @@ public class AreaPtg
|
|||||||
field_4_last_column = column;
|
field_4_last_column = column;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return toFormulaString(this, book);
|
return toFormulaString(this, book);
|
||||||
}
|
}
|
||||||
protected static String toFormulaString(AreaI area, HSSFWorkbook book) {
|
protected static String toFormulaString(AreaI area, Workbook book) {
|
||||||
CellReference topLeft = new CellReference(area.getFirstRow(),area.getFirstColumn(),!area.isFirstRowRelative(),!area.isFirstColRelative());
|
CellReference topLeft = new CellReference(area.getFirstRow(),area.getFirstColumn(),!area.isFirstRowRelative(),!area.isFirstColRelative());
|
||||||
CellReference botRight = new CellReference(area.getLastRow(),area.getLastColumn(),!area.isLastRowRelative(),!area.isLastColRelative());
|
CellReference botRight = new CellReference(area.getLastRow(),area.getLastColumn(),!area.isLastRowRelative(),!area.isLastColRelative());
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ import org.apache.poi.util.BitField;
|
|||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
import org.apache.poi.hssf.util.AreaReference;
|
import org.apache.poi.hssf.util.AreaReference;
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.hssf.util.CellReference;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies a rectangular area of cells A1:A4 for instance.
|
* Specifies a rectangular area of cells A1:A4 for instance.
|
||||||
|
@ -23,7 +23,7 @@ import org.apache.poi.util.BitFieldFactory;
|
|||||||
import org.apache.poi.util.StringUtil;
|
import org.apache.poi.util.StringUtil;
|
||||||
|
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.hssf.util.CellReference;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordFormatException;
|
import org.apache.poi.hssf.record.RecordFormatException;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
import org.apache.poi.hssf.record.SSTRecord;
|
import org.apache.poi.hssf.record.SSTRecord;
|
||||||
@ -198,7 +198,7 @@ public class ArrayPtg extends Ptg
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
StringBuffer b = new StringBuffer();
|
StringBuffer b = new StringBuffer();
|
||||||
b.append("{");
|
b.append("{");
|
||||||
|
@ -23,7 +23,7 @@ import org.apache.poi.util.BitFieldFactory;
|
|||||||
import org.apache.poi.util.StringUtil;
|
import org.apache.poi.util.StringUtil;
|
||||||
|
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.hssf.util.CellReference;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordFormatException;
|
import org.apache.poi.hssf.record.RecordFormatException;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
import org.apache.poi.hssf.record.SSTRecord;
|
import org.apache.poi.hssf.record.SSTRecord;
|
||||||
|
@ -23,7 +23,7 @@ import org.apache.poi.util.BitFieldFactory;
|
|||||||
import org.apache.poi.util.StringUtil;
|
import org.apache.poi.util.StringUtil;
|
||||||
|
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.hssf.util.CellReference;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordFormatException;
|
import org.apache.poi.hssf.record.RecordFormatException;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
import org.apache.poi.hssf.record.SSTRecord;
|
import org.apache.poi.hssf.record.SSTRecord;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
@ -209,11 +209,11 @@ public final class AttrPtg extends OperationPtg {
|
|||||||
if(space.isSet(field_1_options)) {
|
if(space.isSet(field_1_options)) {
|
||||||
return operands[ 0 ];
|
return operands[ 0 ];
|
||||||
} else if (optiIf.isSet(field_1_options)) {
|
} else if (optiIf.isSet(field_1_options)) {
|
||||||
return toFormulaString((HSSFWorkbook)null) + "(" + operands[ 0 ] +")";
|
return toFormulaString((Workbook)null) + "(" + operands[ 0 ] +")";
|
||||||
} else if (optGoto.isSet(field_1_options)) {
|
} else if (optGoto.isSet(field_1_options)) {
|
||||||
return toFormulaString((HSSFWorkbook)null) + operands[0]; //goto isn't a real formula element should not show up
|
return toFormulaString((Workbook)null) + operands[0]; //goto isn't a real formula element should not show up
|
||||||
} else {
|
} else {
|
||||||
return toFormulaString((HSSFWorkbook)null) + "(" + operands[ 0 ] + ")";
|
return toFormulaString((Workbook)null) + "(" + operands[ 0 ] + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ public final class AttrPtg extends OperationPtg {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book) {
|
public String toFormulaString(Workbook book) {
|
||||||
if(semiVolatile.isSet(field_1_options)) {
|
if(semiVolatile.isSet(field_1_options)) {
|
||||||
return "ATTR(semiVolatile)";
|
return "ATTR(semiVolatile)";
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,7 +70,7 @@ public class BoolPtg
|
|||||||
return SIZE;
|
return SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return field_1_value ? "TRUE" : "FALSE";
|
return field_1_value ? "TRUE" : "FALSE";
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,7 +64,7 @@ public class ConcatPtg
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return CONCAT;
|
return CONCAT;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,7 +65,7 @@ public class DividePtg
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return "/";
|
return "/";
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ public class DividePtg
|
|||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
|
||||||
buffer.append(operands[ 0 ]);
|
buffer.append(operands[ 0 ]);
|
||||||
buffer.append(toFormulaString((HSSFWorkbook)null));
|
buffer.append(toFormulaString((Workbook)null));
|
||||||
buffer.append(operands[ 1 ]);
|
buffer.append(operands[ 1 ]);
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,7 +64,7 @@ public class EqualPtg
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return "=";
|
return "=";
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ public class EqualPtg
|
|||||||
|
|
||||||
|
|
||||||
buffer.append(operands[ 0 ]);
|
buffer.append(operands[ 0 ]);
|
||||||
buffer.append(toFormulaString((HSSFWorkbook)null));
|
buffer.append(toFormulaString((Workbook)null));
|
||||||
buffer.append(operands[ 1 ]);
|
buffer.append(operands[ 1 ]);
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFErrorConstants;
|
import org.apache.poi.hssf.usermodel.HSSFErrorConstants;
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ public final class ErrPtg extends Ptg {
|
|||||||
array[offset + 1] = (byte)field_1_error_code;
|
array[offset + 1] = (byte)field_1_error_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book) {
|
public String toFormulaString(Workbook book) {
|
||||||
return HSSFErrorConstants.getText(field_1_error_code);
|
return HSSFErrorConstants.getText(field_1_error_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordFormatException;
|
import org.apache.poi.hssf.record.RecordFormatException;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ public class ExpPtg
|
|||||||
return field_2_first_col;
|
return field_2_first_col;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
throw new RecordFormatException("Coding Error: Expected ExpPtg to be converted from Shared to Non-Shared Formula by ValueRecordsAggregate, but it wasn't");
|
throw new RecordFormatException("Coding Error: Expected ExpPtg to be converted from Shared to Non-Shared Formula by ValueRecordsAggregate, but it wasn't");
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public class GreaterEqualPtg
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return ">=";
|
return ">=";
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ public class GreaterEqualPtg
|
|||||||
|
|
||||||
buffer.append(operands[ 0 ]);
|
buffer.append(operands[ 0 ]);
|
||||||
|
|
||||||
buffer.append(toFormulaString((HSSFWorkbook)null));
|
buffer.append(toFormulaString((Workbook)null));
|
||||||
buffer.append(operands[ 1 ]);
|
buffer.append(operands[ 1 ]);
|
||||||
|
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
|
@ -25,7 +25,7 @@ package org.apache.poi.hssf.record.formula;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,7 +97,7 @@ public class GreaterThanPtg
|
|||||||
* Implementation of method from Ptg
|
* Implementation of method from Ptg
|
||||||
* @param book the Sheet References
|
* @param book the Sheet References
|
||||||
*/
|
*/
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return this.GREATERTHAN;
|
return this.GREATERTHAN;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,7 +72,7 @@ public final class IntPtg extends Ptg {
|
|||||||
return SIZE;
|
return SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book) {
|
public String toFormulaString(Workbook book) {
|
||||||
return String.valueOf(getValue());
|
return String.valueOf(getValue());
|
||||||
}
|
}
|
||||||
public byte getDefaultOperandClass() {
|
public byte getDefaultOperandClass() {
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,7 +59,7 @@ public class IntersectionPtg extends OperationPtg
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Implementation of method from Ptg */
|
/** Implementation of method from Ptg */
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ public class LessEqualPtg
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString( HSSFWorkbook book )
|
public String toFormulaString( Workbook book )
|
||||||
{
|
{
|
||||||
return "<=";
|
return "<=";
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ public class LessEqualPtg
|
|||||||
{
|
{
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append( operands[0] );
|
buffer.append( operands[0] );
|
||||||
buffer.append( toFormulaString( (HSSFWorkbook) null ) );
|
buffer.append( toFormulaString( (Workbook) null ) );
|
||||||
buffer.append( operands[1] );
|
buffer.append( operands[1] );
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ package org.apache.poi.hssf.record.formula;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
//POI
|
//POI
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -106,7 +106,7 @@ public class LessThanPtg
|
|||||||
* Implementation of method from Ptg
|
* Implementation of method from Ptg
|
||||||
* @param book the Sheet References
|
* @param book the Sheet References
|
||||||
*/
|
*/
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return this.LESSTHAN;
|
return this.LESSTHAN;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,7 +83,7 @@ public class MemAreaPtg
|
|||||||
return SIZE;
|
return SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return ""; // TODO: Not sure how to format this. -- DN
|
return ""; // TODO: Not sure how to format this. -- DN
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,7 +57,7 @@ public class MemErrPtg
|
|||||||
array[offset] = (byte) (sid + ptgClass);
|
array[offset] = (byte) (sid + ptgClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return "ERR#";
|
return "ERR#";
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,7 +60,7 @@ public class MemFuncPtg extends ControlPtg
|
|||||||
LittleEndian.putShort( array, offset + 1, (short)field_1_len_ref_subexpression );
|
LittleEndian.putShort( array, offset + 1, (short)field_1_len_ref_subexpression );
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,7 +55,7 @@ public class MissingArgPtg
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
==================================================================== */
|
==================================================================== */
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,7 +68,7 @@ public class MultiplyPtg
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return "*";
|
return "*";
|
||||||
}
|
}
|
||||||
@ -77,9 +77,9 @@ public class MultiplyPtg
|
|||||||
{
|
{
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
|
||||||
buffer.append(operands[ 0 ].toFormulaString((HSSFWorkbook)null));
|
buffer.append(operands[ 0 ].toFormulaString((Workbook)null));
|
||||||
buffer.append("*");
|
buffer.append("*");
|
||||||
buffer.append(operands[ 1 ].toFormulaString((HSSFWorkbook)null));
|
buffer.append(operands[ 1 ].toFormulaString((Workbook)null));
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ public class MultiplyPtg
|
|||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
|
||||||
buffer.append(operands[ 0 ]);
|
buffer.append(operands[ 0 ]);
|
||||||
buffer.append(toFormulaString((HSSFWorkbook)null));
|
buffer.append(toFormulaString((Workbook)null));
|
||||||
buffer.append(operands[ 1 ]);
|
buffer.append(operands[ 1 ]);
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,10 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFName;
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
||||||
import org.apache.poi.hssf.record.NameRecord;
|
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
import org.apache.poi.ss.usermodel.Name;
|
||||||
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -49,13 +48,13 @@ public class NamePtg
|
|||||||
* in the workbook. The search for the name record is case insensitive. If it is not found,
|
* in the workbook. The search for the name record is case insensitive. If it is not found,
|
||||||
* it gets created.
|
* it gets created.
|
||||||
*/
|
*/
|
||||||
public NamePtg(String name, HSSFWorkbook book) {
|
public NamePtg(String name, Workbook book) {
|
||||||
field_1_label_index = (short)(1+getOrCreateNameRecord(book, name)); // convert to 1-based
|
field_1_label_index = (short)(1+getOrCreateNameRecord(book, name)); // convert to 1-based
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @return zero based index of the found or newly created defined name record.
|
* @return zero based index of the found or newly created defined name record.
|
||||||
*/
|
*/
|
||||||
private static final int getOrCreateNameRecord(HSSFWorkbook book, String name) {
|
private static final int getOrCreateNameRecord(Workbook book, String name) {
|
||||||
// perhaps this logic belongs in Workbook?
|
// perhaps this logic belongs in Workbook?
|
||||||
int countNames = book.getNumberOfNames();
|
int countNames = book.getNumberOfNames();
|
||||||
for (int i = 0; i < countNames; i++) {
|
for (int i = 0; i < countNames; i++) {
|
||||||
@ -64,7 +63,7 @@ public class NamePtg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HSSFName nameObj = book.createName();
|
Name nameObj = book.createName();
|
||||||
nameObj.setNameName(name);
|
nameObj.setNameName(name);
|
||||||
|
|
||||||
return countNames;
|
return countNames;
|
||||||
@ -99,7 +98,7 @@ public class NamePtg
|
|||||||
return SIZE;
|
return SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return book.getNameName(field_1_label_index - 1);
|
return book.getNameName(field_1_label_index - 1);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,7 +61,7 @@ public final class NameXPtg extends Ptg {
|
|||||||
return SIZE;
|
return SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
// -1 to convert definedNameIndex from 1-based to zero-based
|
// -1 to convert definedNameIndex from 1-based to zero-based
|
||||||
return book.resolveNameXText(field_1_ixals, field_2_ilbl-1);
|
return book.resolveNameXText(field_1_ixals, field_2_ilbl-1);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,7 +64,7 @@ public class NotEqualPtg
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString( HSSFWorkbook book )
|
public String toFormulaString( Workbook book )
|
||||||
{
|
{
|
||||||
return "<>";
|
return "<>";
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ public class NotEqualPtg
|
|||||||
|
|
||||||
buffer.append( operands[0] );
|
buffer.append( operands[0] );
|
||||||
|
|
||||||
buffer.append( toFormulaString( (HSSFWorkbook) null ) );
|
buffer.append( toFormulaString( (Workbook) null ) );
|
||||||
buffer.append( operands[1] );
|
buffer.append( operands[1] );
|
||||||
|
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,7 +78,7 @@ public class NumberPtg
|
|||||||
return SIZE;
|
return SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return "" + getValue();
|
return "" + getValue();
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ package org.apache.poi.hssf.record.formula;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,7 +71,7 @@ public class ParenthesisPtg
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return "()";
|
return "()";
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,7 +74,7 @@ public class PercentPtg
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Implementation of method from Ptg */
|
/** Implementation of method from Ptg */
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return "%";
|
return "%";
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ package org.apache.poi.hssf.record.formula;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,7 +66,7 @@ public class PowerPtg
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return "^";
|
return "^";
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ public class PowerPtg
|
|||||||
|
|
||||||
|
|
||||||
buffer.append(operands[ 0 ]);
|
buffer.append(operands[ 0 ]);
|
||||||
buffer.append(toFormulaString((HSSFWorkbook)null));
|
buffer.append(toFormulaString((Workbook)null));
|
||||||
buffer.append(operands[ 1 ]);
|
buffer.append(operands[ 1 ]);
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import java.util.List;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -418,7 +418,7 @@ public abstract class Ptg
|
|||||||
/**
|
/**
|
||||||
* return a string representation of this token alone
|
* return a string representation of this token alone
|
||||||
*/
|
*/
|
||||||
public abstract String toFormulaString(HSSFWorkbook book);
|
public abstract String toFormulaString(Workbook book);
|
||||||
/**
|
/**
|
||||||
* dump a debug representation (hexdump) to a string
|
* dump a debug representation (hexdump) to a string
|
||||||
*/
|
*/
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,7 +59,7 @@ public class RangePtg extends OperationPtg
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Implementation of method from Ptg */
|
/** Implementation of method from Ptg */
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return ":";
|
return ":";
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,11 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
|
||||||
import org.apache.poi.hssf.util.RangeAddress;
|
import org.apache.poi.hssf.util.RangeAddress;
|
||||||
import org.apache.poi.hssf.util.SheetReferences;
|
import org.apache.poi.ss.util.CellReference;
|
||||||
|
import org.apache.poi.ss.util.SheetReferences;
|
||||||
import org.apache.poi.util.BitField;
|
import org.apache.poi.util.BitField;
|
||||||
import org.apache.poi.util.BitFieldFactory;
|
import org.apache.poi.util.BitFieldFactory;
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
@ -162,8 +162,8 @@ public class Ref3DPtg extends Ptg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO - find a home for this method
|
// TODO - find a home for this method
|
||||||
// There is already a method on HSSFWorkbook called getSheetName but it seems to do something different.
|
// There is already a method on Workbook called getSheetName but it seems to do something different.
|
||||||
static String getSheetName(HSSFWorkbook book, int externSheetIndex) {
|
static String getSheetName(Workbook book, int externSheetIndex) {
|
||||||
// TODO - there are 3 ways this method can return null. Is each valid?
|
// TODO - there are 3 ways this method can return null. Is each valid?
|
||||||
if (book == null) {
|
if (book == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -179,7 +179,7 @@ public class Ref3DPtg extends Ptg {
|
|||||||
* @return text representation of this cell reference that can be used in text
|
* @return text representation of this cell reference that can be used in text
|
||||||
* formulas. The sheet name will get properly delimited if required.
|
* formulas. The sheet name will get properly delimited if required.
|
||||||
*/
|
*/
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
StringBuffer retval = new StringBuffer();
|
StringBuffer retval = new StringBuffer();
|
||||||
String sheetName = getSheetName(book, field_1_index_extern_sheet);
|
String sheetName = getSheetName(book, field_1_index_extern_sheet);
|
||||||
|
@ -21,7 +21,7 @@ import org.apache.poi.util.LittleEndian;
|
|||||||
import org.apache.poi.util.BitField;
|
import org.apache.poi.util.BitField;
|
||||||
|
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.hssf.util.CellReference;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,7 +74,7 @@ public class RefErrorPtg extends Ptg
|
|||||||
return SIZE;
|
return SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
//TODO -- should we store a cellreference instance in this ptg?? but .. memory is an issue, i believe!
|
//TODO -- should we store a cellreference instance in this ptg?? but .. memory is an issue, i believe!
|
||||||
return "#REF!";
|
return "#REF!";
|
||||||
|
@ -28,7 +28,7 @@ import org.apache.poi.util.BitField;
|
|||||||
|
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.hssf.util.CellReference;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RefNAPtg
|
* RefNAPtg
|
||||||
@ -57,7 +57,7 @@ public class RefNAPtg extends ReferencePtg
|
|||||||
return "RefNAPtg";
|
return "RefNAPtg";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
|
throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ import org.apache.poi.util.BitField;
|
|||||||
|
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.hssf.util.CellReference;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RefNPtg
|
* RefNPtg
|
||||||
@ -58,7 +58,7 @@ public class RefNPtg extends ReferencePtg
|
|||||||
return "RefNPtg";
|
return "RefNPtg";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
|
throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import org.apache.poi.util.BitField;
|
|||||||
|
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.hssf.util.CellReference;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RefNVPtg
|
* RefNVPtg
|
||||||
@ -54,7 +54,7 @@ public class RefNVPtg extends ReferencePtg
|
|||||||
return "RefNVPtg";
|
return "RefNVPtg";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
|
throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import org.apache.poi.util.BitField;
|
|||||||
import org.apache.poi.util.BitFieldFactory;
|
import org.apache.poi.util.BitFieldFactory;
|
||||||
|
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.hssf.util.CellReference;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -176,7 +176,7 @@ public class ReferencePtg extends Ptg {
|
|||||||
return SIZE;
|
return SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
//TODO -- should we store a cellreference instance in this ptg?? but .. memory is an issue, i believe!
|
//TODO -- should we store a cellreference instance in this ptg?? but .. memory is an issue, i believe!
|
||||||
return (new CellReference(getRowAsInt(),getColumn(),!isRowRelative(),!isColRelative())).formatAsString();
|
return (new CellReference(getRowAsInt(),getColumn(),!isRowRelative(),!isColRelative())).formatAsString();
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.util.BitField;
|
import org.apache.poi.util.BitField;
|
||||||
import org.apache.poi.util.BitFieldFactory;
|
import org.apache.poi.util.BitFieldFactory;
|
||||||
import org.apache.poi.util.StringUtil;
|
import org.apache.poi.util.StringUtil;
|
||||||
@ -109,7 +109,7 @@ public class StringPtg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return "\""+getValue()+"\"";
|
return "\""+getValue()+"\"";
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,7 +63,7 @@ public class SubtractPtg
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return "-";
|
return "-";
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ package org.apache.poi.hssf.record.formula;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,7 +69,7 @@ public class UnaryMinusPtg extends OperationPtg
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Implementation of method from Ptg */
|
/** Implementation of method from Ptg */
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return "+";
|
return "+";
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ package org.apache.poi.hssf.record.formula;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,7 +69,7 @@ public class UnaryPlusPtg extends OperationPtg
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Implementation of method from Ptg */
|
/** Implementation of method from Ptg */
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return "+";
|
return "+";
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,7 +59,7 @@ public class UnionPtg extends OperationPtg
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Implementation of method from Ptg */
|
/** Implementation of method from Ptg */
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return ",";
|
return ",";
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
==================================================================== */
|
==================================================================== */
|
||||||
package org.apache.poi.hssf.record.formula;
|
package org.apache.poi.hssf.record.formula;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.hssf.record.RecordInputStream;
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,7 +51,7 @@ public class UnknownPtg
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString(HSSFWorkbook book)
|
public String toFormulaString(Workbook book)
|
||||||
{
|
{
|
||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,8 @@ public class HSSFName implements Name {
|
|||||||
private void setSheetName(String sheetName){
|
private void setSheetName(String sheetName){
|
||||||
int sheetNumber = book.getSheetIndex(sheetName);
|
int sheetNumber = book.getSheetIndex(sheetName);
|
||||||
|
|
||||||
short externSheetNumber = book.getExternalSheetIndex(sheetNumber);
|
short externSheetNumber = (short)
|
||||||
|
book.getExternalSheetIndex(sheetNumber);
|
||||||
name.setExternSheetNumber(externSheetNumber);
|
name.setExternSheetNumber(externSheetNumber);
|
||||||
// name.setIndexToSheet(externSheetNumber);
|
// name.setIndexToSheet(externSheetNumber);
|
||||||
|
|
||||||
|
@ -548,7 +548,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm
|
|||||||
* Used by some of the more obscure formula and
|
* Used by some of the more obscure formula and
|
||||||
* named range things.
|
* named range things.
|
||||||
*/
|
*/
|
||||||
public short getExternalSheetIndex(int internalSheetIndex) {
|
public int getExternalSheetIndex(int internalSheetIndex) {
|
||||||
return workbook.checkExternSheet(internalSheetIndex);
|
return workbook.checkExternSheet(internalSheetIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,9 +17,6 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.util;
|
package org.apache.poi.hssf.util;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds a collection of Sheet names and their associated
|
* Holds a collection of Sheet names and their associated
|
||||||
* reference numbers.
|
* reference numbers.
|
||||||
@ -27,20 +24,6 @@ import java.util.Map;
|
|||||||
* @author Andrew C. Oliver (acoliver at apache dot org)
|
* @author Andrew C. Oliver (acoliver at apache dot org)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SheetReferences
|
public class SheetReferences extends org.apache.poi.ss.util.SheetReferences
|
||||||
{
|
{
|
||||||
Map map;
|
|
||||||
public SheetReferences()
|
|
||||||
{
|
|
||||||
map = new HashMap(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addSheetReference(String sheetName, int number) {
|
|
||||||
map.put(new Integer(number), sheetName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSheetName(int number) {
|
|
||||||
return (String)map.get(new Integer(number));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,6 @@ import org.apache.poi.hssf.record.formula.eval.RefEval;
|
|||||||
import org.apache.poi.hssf.record.formula.eval.StringEval;
|
import org.apache.poi.hssf.record.formula.eval.StringEval;
|
||||||
import org.apache.poi.hssf.record.formula.eval.ValueEval;
|
import org.apache.poi.hssf.record.formula.eval.ValueEval;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
|
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Amol S. Deshmukh < amolweb at ya hoo dot com >
|
* @author Amol S. Deshmukh < amolweb at ya hoo dot com >
|
||||||
@ -333,16 +332,8 @@ public class FormulaEvaluator {
|
|||||||
private static ValueEval evaluateCell(Workbook workbook, Sheet sheet,
|
private static ValueEval evaluateCell(Workbook workbook, Sheet sheet,
|
||||||
int srcRowNum, short srcColNum, String cellFormulaText) {
|
int srcRowNum, short srcColNum, String cellFormulaText) {
|
||||||
|
|
||||||
FormulaParser parser;
|
FormulaParser parser =
|
||||||
if(workbook instanceof HSSFWorkbook) {
|
new FormulaParser(cellFormulaText, workbook);
|
||||||
parser = HSSFFormulaEvaluator.getUnderlyingParser(
|
|
||||||
(HSSFWorkbook)workbook,
|
|
||||||
cellFormulaText
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// Hope for the best...
|
|
||||||
parser = new FormulaParser(cellFormulaText, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
parser.parse();
|
parser.parse();
|
||||||
Ptg[] ptgs = parser.getRPNPtg();
|
Ptg[] ptgs = parser.getRPNPtg();
|
||||||
|
46
src/java/org/apache/poi/ss/util/SheetReferences.java
Normal file
46
src/java/org/apache/poi/ss/util/SheetReferences.java
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/* ====================================================================
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
==================================================================== */
|
||||||
|
|
||||||
|
package org.apache.poi.ss.util;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holds a collection of Sheet names and their associated
|
||||||
|
* reference numbers.
|
||||||
|
*
|
||||||
|
* @author Andrew C. Oliver (acoliver at apache dot org)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SheetReferences
|
||||||
|
{
|
||||||
|
Map map;
|
||||||
|
public SheetReferences()
|
||||||
|
{
|
||||||
|
map = new HashMap(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSheetReference(String sheetName, int number) {
|
||||||
|
map.put(new Integer(number), sheetName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSheetName(int number) {
|
||||||
|
return (String)map.get(new Integer(number));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -21,6 +21,8 @@ import java.io.IOException;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.poi.ss.util.SheetReferences;
|
||||||
|
|
||||||
public interface Workbook {
|
public interface Workbook {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -141,6 +143,15 @@ public interface Workbook {
|
|||||||
*/
|
*/
|
||||||
int getSheetIndex(Sheet sheet);
|
int getSheetIndex(Sheet sheet);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the external sheet index of the sheet
|
||||||
|
* with the given internal index, creating one
|
||||||
|
* if needed.
|
||||||
|
* Used by some of the more obscure formula and
|
||||||
|
* named range things.
|
||||||
|
*/
|
||||||
|
int getExternalSheetIndex(int internalSheetIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create an HSSFSheet for this HSSFWorkbook, adds it to the sheets and returns
|
* create an HSSFSheet for this HSSFWorkbook, adds it to the sheets and returns
|
||||||
* the high level representation. Use this to create new sheets.
|
* the high level representation. Use this to create new sheets.
|
||||||
@ -206,6 +217,8 @@ public interface Workbook {
|
|||||||
|
|
||||||
void removeSheetAt(int index);
|
void removeSheetAt(int index);
|
||||||
|
|
||||||
|
SheetReferences getSheetReferences();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* determine whether the Excel GUI will backup the workbook when saving.
|
* determine whether the Excel GUI will backup the workbook when saving.
|
||||||
*
|
*
|
||||||
@ -352,6 +365,14 @@ public interface Workbook {
|
|||||||
*/
|
*/
|
||||||
String getNameName(int index);
|
String getNameName(int index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO - make this less cryptic / move elsewhere
|
||||||
|
* @param refIndex Index to REF entry in EXTERNSHEET record in the Link Table
|
||||||
|
* @param definedNameIndex zero-based to DEFINEDNAME or EXTERNALNAME record
|
||||||
|
* @return the string representation of the defined or external name
|
||||||
|
*/
|
||||||
|
String resolveNameXText(int refIndex, int definedNameIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the printarea for the sheet provided
|
* Sets the printarea for the sheet provided
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -39,6 +39,7 @@ import org.apache.poi.ss.usermodel.SharedStringSource;
|
|||||||
import org.apache.poi.ss.usermodel.Sheet;
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
import org.apache.poi.ss.usermodel.StylesSource;
|
import org.apache.poi.ss.usermodel.StylesSource;
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
import org.apache.poi.ss.util.SheetReferences;
|
||||||
import org.apache.poi.util.POILogFactory;
|
import org.apache.poi.util.POILogFactory;
|
||||||
import org.apache.poi.util.POILogger;
|
import org.apache.poi.util.POILogger;
|
||||||
import org.apache.poi.xssf.model.CommentsTable;
|
import org.apache.poi.xssf.model.CommentsTable;
|
||||||
@ -498,8 +499,17 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO - figure out what the hell this methods does in
|
||||||
|
* HSSF...
|
||||||
|
*/
|
||||||
|
public String resolveNameXText(int refIndex, int definedNameIndex) {
|
||||||
|
// TODO Replace with something proper
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public short getNumCellStyles() {
|
public short getNumCellStyles() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -573,12 +583,33 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
|
|||||||
public int getSheetIndex(Sheet sheet) {
|
public int getSheetIndex(Sheet sheet) {
|
||||||
return this.sheets.indexOf(sheet);
|
return this.sheets.indexOf(sheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the external sheet index of the sheet
|
||||||
|
* with the given internal index, creating one
|
||||||
|
* if needed.
|
||||||
|
* Used by some of the more obscure formula and
|
||||||
|
* named range things.
|
||||||
|
* Fairly easy on XSSF (we think...) since the
|
||||||
|
* internal and external indicies are the same
|
||||||
|
*/
|
||||||
|
public int getExternalSheetIndex(int internalSheetIndex) {
|
||||||
|
return internalSheetIndex;
|
||||||
|
}
|
||||||
|
|
||||||
public String getSheetName(int sheet) {
|
public String getSheetName(int sheet) {
|
||||||
return this.workbook.getSheets().getSheetArray(sheet).getName();
|
return this.workbook.getSheets().getSheetArray(sheet).getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SheetReferences getSheetReferences() {
|
||||||
|
SheetReferences sr = new SheetReferences();
|
||||||
|
for(int i=0; i<getNumberOfSheets(); i++) {
|
||||||
|
sr.addSheetReference(getSheetName(i), i);
|
||||||
|
}
|
||||||
|
return sr;
|
||||||
|
}
|
||||||
|
|
||||||
public void insertChartRecord() {
|
public void insertChartRecord() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user