mirror of https://github.com/apache/poi.git
Renamed model.Workbook to InternalWorkbook to alleviate name clash.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@893050 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
66d86cb8da
commit
1fd52310cd
|
@ -20,7 +20,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.poi.hssf.model.HSSFFormulaParser;
|
import org.apache.poi.hssf.model.HSSFFormulaParser;
|
||||||
import org.apache.poi.hssf.model.Workbook;
|
import org.apache.poi.hssf.model.InternalWorkbook;
|
||||||
import org.apache.poi.hssf.record.BoundSheetRecord;
|
import org.apache.poi.hssf.record.BoundSheetRecord;
|
||||||
import org.apache.poi.hssf.record.EOFRecord;
|
import org.apache.poi.hssf.record.EOFRecord;
|
||||||
import org.apache.poi.hssf.record.ExternSheetRecord;
|
import org.apache.poi.hssf.record.ExternSheetRecord;
|
||||||
|
@ -30,39 +30,31 @@ import org.apache.poi.hssf.record.SupBookRecord;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When working with the EventUserModel, if you want to
|
* When working with the EventUserModel, if you want to
|
||||||
* process formulas, you need an instance of
|
* process formulas, you need an instance of
|
||||||
* {@link Workbook} to pass to a {@link HSSFWorkbook},
|
* {@link InternalWorkbook} to pass to a {@link HSSFWorkbook},
|
||||||
* to finally give to {@link HSSFFormulaParser},
|
* to finally give to {@link HSSFFormulaParser},
|
||||||
* and this will build you stub ones.
|
* and this will build you stub ones.
|
||||||
* Since you're working with the EventUserModel, you
|
* Since you're working with the EventUserModel, you
|
||||||
* wouldn't want to get a full {@link Workbook} and
|
* wouldn't want to get a full {@link InternalWorkbook} and
|
||||||
* {@link HSSFWorkbook}, as they would eat too much memory.
|
* {@link HSSFWorkbook}, as they would eat too much memory.
|
||||||
* Instead, you should collect a few key records as they
|
* Instead, you should collect a few key records as they
|
||||||
* go past, then call this once you have them to build a
|
* go past, then call this once you have them to build a
|
||||||
* stub {@link Workbook}, and from that a stub
|
* stub {@link InternalWorkbook}, and from that a stub
|
||||||
* {@link HSSFWorkbook}, to use with the {@link HSSFFormulaParser}.
|
* {@link HSSFWorkbook}, to use with the {@link HSSFFormulaParser}.
|
||||||
*
|
*
|
||||||
* The records you should collect are:
|
* The records you should collect are:
|
||||||
* * {@link ExternSheetRecord}
|
* * {@link ExternSheetRecord}
|
||||||
* * {@link BoundSheetRecord}
|
* * {@link BoundSheetRecord}
|
||||||
* You should probably also collect {@link SSTRecord},
|
* You should probably also collect {@link SSTRecord},
|
||||||
* but it's not required to pass this in.
|
* but it's not required to pass this in.
|
||||||
*
|
*
|
||||||
* To help, this class includes a HSSFListener wrapper
|
* To help, this class includes a HSSFListener wrapper
|
||||||
* that will do the collecting for you.
|
* that will do the collecting for you.
|
||||||
*/
|
*/
|
||||||
public class EventWorkbookBuilder {
|
public class EventWorkbookBuilder {
|
||||||
/**
|
|
||||||
* Wraps up your stub {@link Workbook} as a stub
|
|
||||||
* {@link HSSFWorkbook}, ready for passing to
|
|
||||||
* {@link HSSFFormulaParser}
|
|
||||||
* @param workbook A stub {@link Workbook}
|
|
||||||
*/
|
|
||||||
public static HSSFWorkbook createStubHSSFWorkbook(Workbook workbook) {
|
|
||||||
return new StubHSSFWorkbook(workbook);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a stub Workbook from the supplied records,
|
* Creates a stub Workbook from the supplied records,
|
||||||
* suitable for use with the {@link HSSFFormulaParser}
|
* suitable for use with the {@link HSSFFormulaParser}
|
||||||
|
@ -71,10 +63,10 @@ public class EventWorkbookBuilder {
|
||||||
* @param sst The SSTRecord in your file.
|
* @param sst The SSTRecord in your file.
|
||||||
* @return A stub Workbook suitable for use with {@link HSSFFormulaParser}
|
* @return A stub Workbook suitable for use with {@link HSSFFormulaParser}
|
||||||
*/
|
*/
|
||||||
public static Workbook createStubWorkbook(ExternSheetRecord[] externs,
|
public static InternalWorkbook createStubWorkbook(ExternSheetRecord[] externs,
|
||||||
BoundSheetRecord[] bounds, SSTRecord sst) {
|
BoundSheetRecord[] bounds, SSTRecord sst) {
|
||||||
List wbRecords = new ArrayList();
|
List wbRecords = new ArrayList();
|
||||||
|
|
||||||
// Core Workbook records go first
|
// Core Workbook records go first
|
||||||
if(bounds != null) {
|
if(bounds != null) {
|
||||||
for(int i=0; i<bounds.length; i++) {
|
for(int i=0; i<bounds.length; i++) {
|
||||||
|
@ -84,7 +76,7 @@ public class EventWorkbookBuilder {
|
||||||
if(sst != null) {
|
if(sst != null) {
|
||||||
wbRecords.add(sst);
|
wbRecords.add(sst);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we can have the ExternSheetRecords,
|
// Now we can have the ExternSheetRecords,
|
||||||
// preceded by a SupBookRecord
|
// preceded by a SupBookRecord
|
||||||
if(externs != null) {
|
if(externs != null) {
|
||||||
|
@ -94,13 +86,13 @@ public class EventWorkbookBuilder {
|
||||||
wbRecords.add(externs[i]);
|
wbRecords.add(externs[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally we need an EoF record
|
// Finally we need an EoF record
|
||||||
wbRecords.add(EOFRecord.instance);
|
wbRecords.add(EOFRecord.instance);
|
||||||
|
|
||||||
return Workbook.createWorkbook(wbRecords);
|
return InternalWorkbook.createWorkbook(wbRecords);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a stub workbook from the supplied records,
|
* Creates a stub workbook from the supplied records,
|
||||||
* suitable for use with the {@link HSSFFormulaParser}
|
* suitable for use with the {@link HSSFFormulaParser}
|
||||||
|
@ -108,16 +100,16 @@ public class EventWorkbookBuilder {
|
||||||
* @param bounds The BoundSheetRecords in your file
|
* @param bounds The BoundSheetRecords in your file
|
||||||
* @return A stub Workbook suitable for use with {@link HSSFFormulaParser}
|
* @return A stub Workbook suitable for use with {@link HSSFFormulaParser}
|
||||||
*/
|
*/
|
||||||
public static Workbook createStubWorkbook(ExternSheetRecord[] externs,
|
public static InternalWorkbook createStubWorkbook(ExternSheetRecord[] externs,
|
||||||
BoundSheetRecord[] bounds) {
|
BoundSheetRecord[] bounds) {
|
||||||
return createStubWorkbook(externs, bounds, null);
|
return createStubWorkbook(externs, bounds, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A wrapping HSSFListener which will collect
|
* A wrapping HSSFListener which will collect
|
||||||
* {@link BoundSheetRecord}s and {@link ExternSheetRecord}s as
|
* {@link BoundSheetRecord}s and {@link ExternSheetRecord}s as
|
||||||
* they go past, so you can create a Stub {@link Workbook} from
|
* they go past, so you can create a Stub {@link InternalWorkbook} from
|
||||||
* them once required.
|
* them once required.
|
||||||
*/
|
*/
|
||||||
public static class SheetRecordCollectingListener implements HSSFListener {
|
public static class SheetRecordCollectingListener implements HSSFListener {
|
||||||
|
@ -125,12 +117,12 @@ public class EventWorkbookBuilder {
|
||||||
private List boundSheetRecords = new ArrayList();
|
private List boundSheetRecords = new ArrayList();
|
||||||
private List externSheetRecords = new ArrayList();
|
private List externSheetRecords = new ArrayList();
|
||||||
private SSTRecord sstRecord = null;
|
private SSTRecord sstRecord = null;
|
||||||
|
|
||||||
public SheetRecordCollectingListener(HSSFListener childListener) {
|
public SheetRecordCollectingListener(HSSFListener childListener) {
|
||||||
this.childListener = childListener;
|
this.childListener = childListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public BoundSheetRecord[] getBoundSheetRecords() {
|
public BoundSheetRecord[] getBoundSheetRecords() {
|
||||||
return (BoundSheetRecord[])boundSheetRecords.toArray(
|
return (BoundSheetRecord[])boundSheetRecords.toArray(
|
||||||
new BoundSheetRecord[boundSheetRecords.size()]
|
new BoundSheetRecord[boundSheetRecords.size()]
|
||||||
|
@ -144,20 +136,18 @@ public class EventWorkbookBuilder {
|
||||||
public SSTRecord getSSTRecord() {
|
public SSTRecord getSSTRecord() {
|
||||||
return sstRecord;
|
return sstRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HSSFWorkbook getStubHSSFWorkbook() {
|
public HSSFWorkbook getStubHSSFWorkbook() {
|
||||||
return createStubHSSFWorkbook(
|
return HSSFWorkbook.create(getStubWorkbook());
|
||||||
getStubWorkbook()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
public Workbook getStubWorkbook() {
|
public InternalWorkbook getStubWorkbook() {
|
||||||
return createStubWorkbook(
|
return createStubWorkbook(
|
||||||
getExternSheetRecords(), getBoundSheetRecords(),
|
getExternSheetRecords(), getBoundSheetRecords(),
|
||||||
getSSTRecord()
|
getSSTRecord()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process this record ourselves, and then
|
* Process this record ourselves, and then
|
||||||
* pass it on to our child listener
|
* pass it on to our child listener
|
||||||
|
@ -165,11 +155,11 @@ public class EventWorkbookBuilder {
|
||||||
public void processRecord(Record record) {
|
public void processRecord(Record record) {
|
||||||
// Handle it ourselves
|
// Handle it ourselves
|
||||||
processRecordInternally(record);
|
processRecordInternally(record);
|
||||||
|
|
||||||
// Now pass on to our child
|
// Now pass on to our child
|
||||||
childListener.processRecord(record);
|
childListener.processRecord(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process the record ourselves, but do not
|
* Process the record ourselves, but do not
|
||||||
* pass it on to the child Listener.
|
* pass it on to the child Listener.
|
||||||
|
@ -186,14 +176,4 @@ public class EventWorkbookBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Let us at the {@link Workbook} constructor on
|
|
||||||
* {@link HSSFWorkbook}
|
|
||||||
*/
|
|
||||||
private static class StubHSSFWorkbook extends HSSFWorkbook {
|
|
||||||
private StubHSSFWorkbook(Workbook wb) {
|
|
||||||
super(wb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ import org.apache.poi.hssf.record.formula.FormulaShifter;
|
||||||
import org.apache.poi.hssf.record.formula.Ptg;
|
import org.apache.poi.hssf.record.formula.Ptg;
|
||||||
import org.apache.poi.hssf.util.HSSFColor;
|
import org.apache.poi.hssf.util.HSSFColor;
|
||||||
import org.apache.poi.ss.formula.EvaluationWorkbook.ExternalSheet;
|
import org.apache.poi.ss.formula.EvaluationWorkbook.ExternalSheet;
|
||||||
|
import org.apache.poi.util.Internal;
|
||||||
import org.apache.poi.util.POILogFactory;
|
import org.apache.poi.util.POILogFactory;
|
||||||
import org.apache.poi.util.POILogger;
|
import org.apache.poi.util.POILogger;
|
||||||
|
|
||||||
|
@ -108,7 +109,8 @@ import org.apache.poi.util.POILogger;
|
||||||
* @author Glen Stampoultzis (glens at apache.org)
|
* @author Glen Stampoultzis (glens at apache.org)
|
||||||
* @see org.apache.poi.hssf.usermodel.HSSFWorkbook
|
* @see org.apache.poi.hssf.usermodel.HSSFWorkbook
|
||||||
*/
|
*/
|
||||||
public final class Workbook {
|
@Internal
|
||||||
|
public final class InternalWorkbook {
|
||||||
/**
|
/**
|
||||||
* Excel silently truncates long sheet names to 31 chars.
|
* Excel silently truncates long sheet names to 31 chars.
|
||||||
* This constant is used to ensure uniqueness in the first 31 chars
|
* This constant is used to ensure uniqueness in the first 31 chars
|
||||||
|
@ -116,7 +118,7 @@ public final class Workbook {
|
||||||
private static final int MAX_SENSITIVE_SHEET_NAME_LEN = 31;
|
private static final int MAX_SENSITIVE_SHEET_NAME_LEN = 31;
|
||||||
|
|
||||||
|
|
||||||
private static final POILogger log = POILogFactory.getLogger(Workbook.class);
|
private static final POILogger log = POILogFactory.getLogger(InternalWorkbook.class);
|
||||||
private static final int DEBUG = POILogger.DEBUG;
|
private static final int DEBUG = POILogger.DEBUG;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -162,7 +164,7 @@ public final class Workbook {
|
||||||
private WriteAccessRecord writeAccess;
|
private WriteAccessRecord writeAccess;
|
||||||
private WriteProtectRecord writeProtect;
|
private WriteProtectRecord writeProtect;
|
||||||
|
|
||||||
private Workbook() {
|
private InternalWorkbook() {
|
||||||
records = new WorkbookRecordList();
|
records = new WorkbookRecordList();
|
||||||
|
|
||||||
boundsheets = new ArrayList<BoundSheetRecord>();
|
boundsheets = new ArrayList<BoundSheetRecord>();
|
||||||
|
@ -187,11 +189,11 @@ public final class Workbook {
|
||||||
* @param recs an array of Record objects
|
* @param recs an array of Record objects
|
||||||
* @return Workbook object
|
* @return Workbook object
|
||||||
*/
|
*/
|
||||||
public static Workbook createWorkbook(List<Record> recs) {
|
public static InternalWorkbook createWorkbook(List<Record> recs) {
|
||||||
if (log.check( POILogger.DEBUG ))
|
if (log.check( POILogger.DEBUG ))
|
||||||
log.log(DEBUG, "Workbook (readfile) created with reclen=",
|
log.log(DEBUG, "Workbook (readfile) created with reclen=",
|
||||||
Integer.valueOf(recs.size()));
|
Integer.valueOf(recs.size()));
|
||||||
Workbook retval = new Workbook();
|
InternalWorkbook retval = new InternalWorkbook();
|
||||||
List<Record> records = new ArrayList<Record>(recs.size() / 3);
|
List<Record> records = new ArrayList<Record>(recs.size() / 3);
|
||||||
retval.records.setRecords(records);
|
retval.records.setRecords(records);
|
||||||
|
|
||||||
|
@ -329,11 +331,11 @@ public final class Workbook {
|
||||||
* Creates an empty workbook object with three blank sheets and all the empty
|
* Creates an empty workbook object with three blank sheets and all the empty
|
||||||
* fields. Use this to create a workbook from scratch.
|
* fields. Use this to create a workbook from scratch.
|
||||||
*/
|
*/
|
||||||
public static Workbook createWorkbook()
|
public static InternalWorkbook createWorkbook()
|
||||||
{
|
{
|
||||||
if (log.check( POILogger.DEBUG ))
|
if (log.check( POILogger.DEBUG ))
|
||||||
log.log( DEBUG, "creating new workbook from scratch" );
|
log.log( DEBUG, "creating new workbook from scratch" );
|
||||||
Workbook retval = new Workbook();
|
InternalWorkbook retval = new InternalWorkbook();
|
||||||
List<Record> records = new ArrayList<Record>( 30 );
|
List<Record> records = new ArrayList<Record>( 30 );
|
||||||
retval.records.setRecords(records);
|
retval.records.setRecords(records);
|
||||||
List<FormatRecord> formats = retval.formats;
|
List<FormatRecord> formats = retval.formats;
|
|
@ -91,7 +91,7 @@ import org.apache.poi.util.POILogger;
|
||||||
* @author Brian Sanders (kestrel at burdell dot org) Active Cell support
|
* @author Brian Sanders (kestrel at burdell dot org) Active Cell support
|
||||||
* @author Jean-Pierre Paris (jean-pierre.paris at m4x dot org) (Just a little)
|
* @author Jean-Pierre Paris (jean-pierre.paris at m4x dot org) (Just a little)
|
||||||
*
|
*
|
||||||
* @see org.apache.poi.hssf.model.Workbook
|
* @see org.apache.poi.hssf.model.InternalWorkbook
|
||||||
* @see org.apache.poi.hssf.usermodel.HSSFSheet
|
* @see org.apache.poi.hssf.usermodel.HSSFSheet
|
||||||
*/
|
*/
|
||||||
public final class Sheet {
|
public final class Sheet {
|
||||||
|
@ -151,7 +151,7 @@ public final class Sheet {
|
||||||
*
|
*
|
||||||
* @return Sheet object with all values set to those read from the file
|
* @return Sheet object with all values set to those read from the file
|
||||||
*
|
*
|
||||||
* @see org.apache.poi.hssf.model.Workbook
|
* @see org.apache.poi.hssf.model.InternalWorkbook
|
||||||
* @see org.apache.poi.hssf.record.Record
|
* @see org.apache.poi.hssf.record.Record
|
||||||
*/
|
*/
|
||||||
public static Sheet createSheet(RecordStream rs) {
|
public static Sheet createSheet(RecordStream rs) {
|
||||||
|
|
|
@ -58,7 +58,7 @@ public final class FormatRecord extends StandardRecord {
|
||||||
* get the format index code (for built in formats)
|
* get the format index code (for built in formats)
|
||||||
*
|
*
|
||||||
* @return the format index code
|
* @return the format index code
|
||||||
* @see org.apache.poi.hssf.model.Workbook
|
* @see org.apache.poi.hssf.model.InternalWorkbook
|
||||||
*/
|
*/
|
||||||
public int getIndexCode() {
|
public int getIndexCode() {
|
||||||
return field_1_index_code;
|
return field_1_index_code;
|
||||||
|
|
|
@ -34,35 +34,32 @@ public final class PaletteRecord extends StandardRecord {
|
||||||
public final static byte STANDARD_PALETTE_SIZE = (byte) 56;
|
public final static byte STANDARD_PALETTE_SIZE = (byte) 56;
|
||||||
/** The byte index of the first color */
|
/** The byte index of the first color */
|
||||||
public final static short FIRST_COLOR_INDEX = (short) 0x8;
|
public final static short FIRST_COLOR_INDEX = (short) 0x8;
|
||||||
|
|
||||||
private List<PColor> field_2_colors;
|
|
||||||
|
|
||||||
public PaletteRecord()
|
private final List<PColor> _colors;
|
||||||
{
|
|
||||||
|
public PaletteRecord() {
|
||||||
PColor[] defaultPalette = createDefaultPalette();
|
PColor[] defaultPalette = createDefaultPalette();
|
||||||
field_2_colors = new ArrayList<PColor>(defaultPalette.length);
|
_colors = new ArrayList<PColor>(defaultPalette.length);
|
||||||
for (int i = 0; i < defaultPalette.length; i++) {
|
for (int i = 0; i < defaultPalette.length; i++) {
|
||||||
field_2_colors.add(defaultPalette[i]);
|
_colors.add(defaultPalette[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PaletteRecord(RecordInputStream in)
|
public PaletteRecord(RecordInputStream in) {
|
||||||
{
|
|
||||||
int field_1_numcolors = in.readShort();
|
int field_1_numcolors = in.readShort();
|
||||||
field_2_colors = new ArrayList<PColor>(field_1_numcolors);
|
_colors = new ArrayList<PColor>(field_1_numcolors);
|
||||||
for (int k = 0; k < field_1_numcolors; k++) {
|
for (int k = 0; k < field_1_numcolors; k++) {
|
||||||
field_2_colors.add(new PColor(in));
|
_colors.add(new PColor(in));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
|
||||||
buffer.append("[PALETTE]\n");
|
buffer.append("[PALETTE]\n");
|
||||||
buffer.append(" numcolors = ").append(field_2_colors.size()).append('\n');
|
buffer.append(" numcolors = ").append(_colors.size()).append('\n');
|
||||||
for (int i = 0; i < field_2_colors.size(); i++) {
|
for (int i = 0; i < _colors.size(); i++) {
|
||||||
PColor c = field_2_colors.get(i);
|
PColor c = _colors.get(i);
|
||||||
buffer.append("* colornum = ").append(i).append('\n');
|
buffer.append("* colornum = ").append(i).append('\n');
|
||||||
buffer.append(c.toString());
|
buffer.append(c.toString());
|
||||||
buffer.append("/*colornum = ").append(i).append('\n');
|
buffer.append("/*colornum = ").append(i).append('\n');
|
||||||
|
@ -71,20 +68,18 @@ public final class PaletteRecord extends StandardRecord {
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(LittleEndianOutput out)
|
public void serialize(LittleEndianOutput out) {
|
||||||
{
|
out.writeShort(_colors.size());
|
||||||
out.writeShort(field_2_colors.size());
|
for (int i = 0; i < _colors.size(); i++) {
|
||||||
for (int i = 0; i < field_2_colors.size(); i++) {
|
_colors.get(i).serialize(out);
|
||||||
field_2_colors.get(i).serialize(out);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getDataSize() {
|
protected int getDataSize() {
|
||||||
return 2 + field_2_colors.size() * PColor.ENCODED_SIZE;
|
return 2 + _colors.size() * PColor.ENCODED_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public short getSid()
|
public short getSid() {
|
||||||
{
|
|
||||||
return sid;
|
return sid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,16 +89,14 @@ public final class PaletteRecord extends StandardRecord {
|
||||||
* @return the RGB triplet for the color, or <code>null</code> if the specified index
|
* @return the RGB triplet for the color, or <code>null</code> if the specified index
|
||||||
* does not exist
|
* does not exist
|
||||||
*/
|
*/
|
||||||
public byte[] getColor(short byteIndex) {
|
public byte[] getColor(int byteIndex) {
|
||||||
int i = byteIndex - FIRST_COLOR_INDEX;
|
int i = byteIndex - FIRST_COLOR_INDEX;
|
||||||
if (i < 0 || i >= field_2_colors.size())
|
if (i < 0 || i >= _colors.size()) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
PColor color = field_2_colors.get(i);
|
return _colors.get(i).getTriplet();
|
||||||
return new byte[] { color.red, color.green, color.blue };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the color value at a given index
|
* Sets the color value at a given index
|
||||||
*
|
*
|
||||||
|
@ -120,18 +113,16 @@ public final class PaletteRecord extends StandardRecord {
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// may need to grow - fill intervening pallette entries with black
|
// may need to grow - fill intervening palette entries with black
|
||||||
while (field_2_colors.size() <= i) {
|
while (_colors.size() <= i) {
|
||||||
field_2_colors.add(new PColor(0, 0, 0));
|
_colors.add(new PColor(0, 0, 0));
|
||||||
}
|
}
|
||||||
PColor custColor = new PColor(red, green, blue);
|
PColor custColor = new PColor(red, green, blue);
|
||||||
field_2_colors.set(i, custColor);
|
_colors.set(i, custColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the default palette as PaletteRecord binary data
|
* Creates the default palette as PaletteRecord binary data
|
||||||
*
|
|
||||||
* @see org.apache.poi.hssf.model.Workbook#createPalette
|
|
||||||
*/
|
*/
|
||||||
private static PColor[] createDefaultPalette()
|
private static PColor[] createDefaultPalette()
|
||||||
{
|
{
|
||||||
|
@ -199,41 +190,45 @@ public final class PaletteRecord extends StandardRecord {
|
||||||
return new PColor(r, g, b);
|
return new PColor(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PColor - element in the list of colors - consider it a "struct"
|
* PColor - element in the list of colors
|
||||||
*/
|
*/
|
||||||
private static final class PColor {
|
private static final class PColor {
|
||||||
public static final short ENCODED_SIZE = 4;
|
public static final short ENCODED_SIZE = 4;
|
||||||
public byte red;
|
private int _red;
|
||||||
public byte green;
|
private int _green;
|
||||||
public byte blue;
|
private int _blue;
|
||||||
|
|
||||||
public PColor(int red, int green, int blue) {
|
public PColor(int red, int green, int blue) {
|
||||||
this.red=(byte) red;
|
_red = red;
|
||||||
this.green=(byte) green;
|
_green = green;
|
||||||
this.blue=(byte) blue;
|
_blue = blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PColor(RecordInputStream in) {
|
public byte[] getTriplet() {
|
||||||
red=in.readByte();
|
return new byte[] { (byte) _red, (byte) _green, (byte) _blue };
|
||||||
green=in.readByte();
|
}
|
||||||
blue=in.readByte();
|
|
||||||
in.readByte(); // unused
|
|
||||||
}
|
|
||||||
|
|
||||||
public void serialize(LittleEndianOutput out) {
|
public PColor(RecordInputStream in) {
|
||||||
out.writeByte(red);
|
_red = in.readByte();
|
||||||
out.writeByte(green);
|
_green = in.readByte();
|
||||||
out.writeByte(blue);
|
_blue = in.readByte();
|
||||||
out.writeByte(0);
|
in.readByte(); // unused
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public void serialize(LittleEndianOutput out) {
|
||||||
StringBuffer buffer = new StringBuffer();
|
out.writeByte(_red);
|
||||||
buffer.append(" red = ").append(red & 0xff).append('\n');
|
out.writeByte(_green);
|
||||||
buffer.append(" green = ").append(green & 0xff).append('\n');
|
out.writeByte(_blue);
|
||||||
buffer.append(" blue = ").append(blue & 0xff).append('\n');
|
out.writeByte(0);
|
||||||
return buffer.toString();
|
}
|
||||||
}
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append(" red = ").append(_red & 0xff).append('\n');
|
||||||
|
buffer.append(" green = ").append(_green & 0xff).append('\n');
|
||||||
|
buffer.append(" blue = ").append(_blue & 0xff).append('\n');
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
|
@ -25,12 +25,10 @@ import org.apache.poi.util.LittleEndianOutput;
|
||||||
* Description: This record contains an ID that marks when a worksheet was last
|
* Description: This record contains an ID that marks when a worksheet was last
|
||||||
* recalculated. It's an optimization Excel uses to determine if it
|
* recalculated. It's an optimization Excel uses to determine if it
|
||||||
* needs to recalculate the spreadsheet when it's opened. So far, only
|
* needs to recalculate the spreadsheet when it's opened. So far, only
|
||||||
* the two engine ids <code>0x80 0x38 0x01 0x00</code>
|
* the two engine ids <code>0x80 0x38 0x01 0x00</code>
|
||||||
* and <code>0x60 0x69 0x01 0x00</code> have been seen.<p/>
|
* and <code>0x60 0x69 0x01 0x00</code> have been seen.<p/>
|
||||||
* REFERENCE: http://chicago.sourceforge.net/devel/docs/excel/biff8.html<p/>
|
* REFERENCE: http://chicago.sourceforge.net/devel/docs/excel/biff8.html<p/>
|
||||||
* @author Luc Girardin (luc dot girardin at macrofocus dot com)
|
* @author Luc Girardin (luc dot girardin at macrofocus dot com)
|
||||||
*
|
|
||||||
* @see org.apache.poi.hssf.model.Workbook
|
|
||||||
*/
|
*/
|
||||||
public final class RecalcIdRecord extends StandardRecord {
|
public final class RecalcIdRecord extends StandardRecord {
|
||||||
public final static short sid = 0x01C1;
|
public final static short sid = 0x01C1;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.util.*;
|
||||||
|
|
||||||
import org.apache.poi.hssf.model.HSSFFormulaParser;
|
import org.apache.poi.hssf.model.HSSFFormulaParser;
|
||||||
import org.apache.poi.hssf.model.Sheet;
|
import org.apache.poi.hssf.model.Sheet;
|
||||||
import org.apache.poi.hssf.model.Workbook;
|
import org.apache.poi.hssf.model.InternalWorkbook;
|
||||||
import org.apache.poi.hssf.record.BlankRecord;
|
import org.apache.poi.hssf.record.BlankRecord;
|
||||||
import org.apache.poi.hssf.record.BoolErrRecord;
|
import org.apache.poi.hssf.record.BoolErrRecord;
|
||||||
import org.apache.poi.hssf.record.CellValueRecordInterface;
|
import org.apache.poi.hssf.record.CellValueRecordInterface;
|
||||||
|
@ -229,7 +229,7 @@ public class HSSFCell implements Cell {
|
||||||
/**
|
/**
|
||||||
* Returns the Workbook that this Cell is bound to
|
* Returns the Workbook that this Cell is bound to
|
||||||
*/
|
*/
|
||||||
protected Workbook getBoundWorkbook() {
|
protected InternalWorkbook getBoundWorkbook() {
|
||||||
return _book.getWorkbook();
|
return _book.getWorkbook();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
package org.apache.poi.hssf.usermodel;
|
package org.apache.poi.hssf.usermodel;
|
||||||
|
|
||||||
import org.apache.poi.hssf.model.Workbook;
|
import org.apache.poi.hssf.model.InternalWorkbook;
|
||||||
import org.apache.poi.hssf.record.ExtendedFormatRecord;
|
import org.apache.poi.hssf.record.ExtendedFormatRecord;
|
||||||
import org.apache.poi.hssf.record.FontRecord;
|
import org.apache.poi.hssf.record.FontRecord;
|
||||||
import org.apache.poi.hssf.record.StyleRecord;
|
import org.apache.poi.hssf.record.StyleRecord;
|
||||||
|
@ -38,7 +38,7 @@ import org.apache.poi.ss.usermodel.Font;
|
||||||
public final class HSSFCellStyle implements CellStyle {
|
public final class HSSFCellStyle implements CellStyle {
|
||||||
private ExtendedFormatRecord _format = null;
|
private ExtendedFormatRecord _format = null;
|
||||||
private short _index = 0;
|
private short _index = 0;
|
||||||
private Workbook _workbook = null;
|
private InternalWorkbook _workbook = null;
|
||||||
|
|
||||||
|
|
||||||
/** Creates new HSSFCellStyle why would you want to do this?? */
|
/** Creates new HSSFCellStyle why would you want to do this?? */
|
||||||
|
@ -46,7 +46,7 @@ public final class HSSFCellStyle implements CellStyle {
|
||||||
{
|
{
|
||||||
this(index, rec, workbook.getWorkbook());
|
this(index, rec, workbook.getWorkbook());
|
||||||
}
|
}
|
||||||
protected HSSFCellStyle(short index, ExtendedFormatRecord rec, Workbook workbook)
|
protected HSSFCellStyle(short index, ExtendedFormatRecord rec, InternalWorkbook workbook)
|
||||||
{
|
{
|
||||||
_workbook = workbook;
|
_workbook = workbook;
|
||||||
_index = index;
|
_index = index;
|
||||||
|
@ -125,7 +125,7 @@ public final class HSSFCellStyle implements CellStyle {
|
||||||
* the DataFormat against the supplied low level workbook
|
* the DataFormat against the supplied low level workbook
|
||||||
* @see org.apache.poi.hssf.usermodel.HSSFDataFormat
|
* @see org.apache.poi.hssf.usermodel.HSSFDataFormat
|
||||||
*/
|
*/
|
||||||
public String getDataFormatString(org.apache.poi.hssf.model.Workbook workbook) {
|
public String getDataFormatString(org.apache.poi.hssf.model.InternalWorkbook workbook) {
|
||||||
HSSFDataFormat format = new HSSFDataFormat( workbook );
|
HSSFDataFormat format = new HSSFDataFormat( workbook );
|
||||||
|
|
||||||
return format.getFormat(getDataFormat());
|
return format.getFormat(getDataFormat());
|
||||||
|
|
|
@ -29,7 +29,7 @@ import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.apache.poi.hssf.model.Workbook;
|
import org.apache.poi.hssf.model.InternalWorkbook;
|
||||||
import org.apache.poi.hssf.record.FormatRecord;
|
import org.apache.poi.hssf.record.FormatRecord;
|
||||||
import org.apache.poi.ss.usermodel.BuiltinFormats;
|
import org.apache.poi.ss.usermodel.BuiltinFormats;
|
||||||
import org.apache.poi.ss.usermodel.DataFormat;
|
import org.apache.poi.ss.usermodel.DataFormat;
|
||||||
|
@ -37,15 +37,15 @@ import org.apache.poi.ss.usermodel.DataFormat;
|
||||||
/**
|
/**
|
||||||
* Identifies both built-in and user defined formats within a workbook.<p/>
|
* Identifies both built-in and user defined formats within a workbook.<p/>
|
||||||
* See {@link BuiltinFormats} for a list of supported built-in formats.<p/>
|
* See {@link BuiltinFormats} for a list of supported built-in formats.<p/>
|
||||||
*
|
*
|
||||||
* <b>International Formats</b><br/>
|
* <b>International Formats</b><br/>
|
||||||
* Since version 2003 Excel has supported international formats. These are denoted
|
* Since version 2003 Excel has supported international formats. These are denoted
|
||||||
* with a prefix "[$-xxx]" (where xxx is a 1-7 digit hexadecimal number).
|
* with a prefix "[$-xxx]" (where xxx is a 1-7 digit hexadecimal number).
|
||||||
* See the Microsoft article
|
* See the Microsoft article
|
||||||
* <a href="http://office.microsoft.com/assistance/hfws.aspx?AssetID=HA010346351033&CTT=6&Origin=EC010272491033">
|
* <a href="http://office.microsoft.com/assistance/hfws.aspx?AssetID=HA010346351033&CTT=6&Origin=EC010272491033">
|
||||||
* Creating international number formats
|
* Creating international number formats
|
||||||
* </a> for more details on these codes.
|
* </a> for more details on these codes.
|
||||||
*
|
*
|
||||||
* @author Andrew C. Oliver (acoliver at apache dot org)
|
* @author Andrew C. Oliver (acoliver at apache dot org)
|
||||||
* @author Shawn M. Laubach (slaubach at apache dot org)
|
* @author Shawn M. Laubach (slaubach at apache dot org)
|
||||||
*/
|
*/
|
||||||
|
@ -53,7 +53,7 @@ public final class HSSFDataFormat implements DataFormat {
|
||||||
private static final String[] _builtinFormats = BuiltinFormats.getAll();
|
private static final String[] _builtinFormats = BuiltinFormats.getAll();
|
||||||
|
|
||||||
private final Vector<String> _formats = new Vector<String>();
|
private final Vector<String> _formats = new Vector<String>();
|
||||||
private final Workbook _workbook;
|
private final InternalWorkbook _workbook;
|
||||||
private boolean _movedBuiltins = false; // Flag to see if need to
|
private boolean _movedBuiltins = false; // Flag to see if need to
|
||||||
// check the built in list
|
// check the built in list
|
||||||
// or if the regular list
|
// or if the regular list
|
||||||
|
@ -64,7 +64,7 @@ public final class HSSFDataFormat implements DataFormat {
|
||||||
* access to the workbooks format records.
|
* access to the workbooks format records.
|
||||||
* @param workbook the workbook the formats are tied to.
|
* @param workbook the workbook the formats are tied to.
|
||||||
*/
|
*/
|
||||||
public HSSFDataFormat(Workbook workbook) {
|
HSSFDataFormat(InternalWorkbook workbook) {
|
||||||
_workbook = workbook;
|
_workbook = workbook;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
package org.apache.poi.hssf.usermodel;
|
package org.apache.poi.hssf.usermodel;
|
||||||
|
|
||||||
import org.apache.poi.hssf.model.HSSFFormulaParser;
|
import org.apache.poi.hssf.model.HSSFFormulaParser;
|
||||||
import org.apache.poi.hssf.model.Workbook;
|
import org.apache.poi.hssf.model.InternalWorkbook;
|
||||||
import org.apache.poi.hssf.record.NameRecord;
|
import org.apache.poi.hssf.record.NameRecord;
|
||||||
import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
|
import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
|
||||||
import org.apache.poi.hssf.record.formula.NamePtg;
|
import org.apache.poi.hssf.record.formula.NamePtg;
|
||||||
|
@ -42,7 +42,7 @@ import org.apache.poi.ss.formula.FormulaType;
|
||||||
public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, EvaluationWorkbook, FormulaParsingWorkbook {
|
public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, EvaluationWorkbook, FormulaParsingWorkbook {
|
||||||
|
|
||||||
private final HSSFWorkbook _uBook;
|
private final HSSFWorkbook _uBook;
|
||||||
private final Workbook _iBook;
|
private final InternalWorkbook _iBook;
|
||||||
|
|
||||||
public static HSSFEvaluationWorkbook create(HSSFWorkbook book) {
|
public static HSSFEvaluationWorkbook create(HSSFWorkbook book) {
|
||||||
if (book == null) {
|
if (book == null) {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
package org.apache.poi.hssf.usermodel;
|
package org.apache.poi.hssf.usermodel;
|
||||||
|
|
||||||
import org.apache.poi.hssf.model.HSSFFormulaParser;
|
import org.apache.poi.hssf.model.HSSFFormulaParser;
|
||||||
import org.apache.poi.hssf.model.Workbook;
|
import org.apache.poi.hssf.model.InternalWorkbook;
|
||||||
import org.apache.poi.hssf.record.NameRecord;
|
import org.apache.poi.hssf.record.NameRecord;
|
||||||
import org.apache.poi.hssf.record.formula.Ptg;
|
import org.apache.poi.hssf.record.formula.Ptg;
|
||||||
import org.apache.poi.ss.formula.FormulaType;
|
import org.apache.poi.ss.formula.FormulaType;
|
||||||
|
@ -114,7 +114,7 @@ public final class HSSFName implements Name {
|
||||||
public void setNameName(String nameName){
|
public void setNameName(String nameName){
|
||||||
validateName(nameName);
|
validateName(nameName);
|
||||||
|
|
||||||
Workbook wb = _book.getWorkbook();
|
InternalWorkbook wb = _book.getWorkbook();
|
||||||
_definedNameRec.setNameText(nameName);
|
_definedNameRec.setNameText(nameName);
|
||||||
|
|
||||||
int sheetNumber = _definedNameRec.getSheetNumber();
|
int sheetNumber = _definedNameRec.getSheetNumber();
|
||||||
|
@ -135,7 +135,7 @@ public final class HSSFName implements Name {
|
||||||
|
|
||||||
private static void validateName(String name){
|
private static void validateName(String name){
|
||||||
if(name.length() == 0) throw new IllegalArgumentException("Name cannot be blank");
|
if(name.length() == 0) throw new IllegalArgumentException("Name cannot be blank");
|
||||||
|
|
||||||
char c = name.charAt(0);
|
char c = name.charAt(0);
|
||||||
if(!(c == '_' || Character.isLetter(c)) || name.indexOf(' ') != -1) {
|
if(!(c == '_' || Character.isLetter(c)) || name.indexOf(' ') != -1) {
|
||||||
throw new IllegalArgumentException("Invalid name: '"+name+"'; Names must begin with a letter or underscore and not contain spaces");
|
throw new IllegalArgumentException("Invalid name: '"+name+"'; Names must begin with a letter or underscore and not contain spaces");
|
||||||
|
@ -249,9 +249,7 @@ public final class HSSFName implements Name {
|
||||||
*
|
*
|
||||||
* @param value <code>true</code> indicates the name refers to a function.
|
* @param value <code>true</code> indicates the name refers to a function.
|
||||||
*/
|
*/
|
||||||
public void setFunction(boolean value) {
|
public void setFunction(boolean value) {
|
||||||
_definedNameRec.setFunction(value);
|
_definedNameRec.setFunction(value);
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.poi.hssf.usermodel;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.apache.poi.hssf.model.Workbook;
|
import org.apache.poi.hssf.model.InternalWorkbook;
|
||||||
import org.apache.poi.hssf.record.LabelSSTRecord;
|
import org.apache.poi.hssf.record.LabelSSTRecord;
|
||||||
import org.apache.poi.hssf.record.UnicodeString;
|
import org.apache.poi.hssf.record.UnicodeString;
|
||||||
import org.apache.poi.ss.usermodel.Font;
|
import org.apache.poi.ss.usermodel.Font;
|
||||||
|
@ -74,7 +74,7 @@ public final class HSSFRichTextString implements Comparable<HSSFRichTextString>,
|
||||||
public static final short NO_FONT = 0;
|
public static final short NO_FONT = 0;
|
||||||
|
|
||||||
private UnicodeString _string;
|
private UnicodeString _string;
|
||||||
private Workbook _book;
|
private InternalWorkbook _book;
|
||||||
private LabelSSTRecord _record;
|
private LabelSSTRecord _record;
|
||||||
|
|
||||||
public HSSFRichTextString()
|
public HSSFRichTextString()
|
||||||
|
@ -90,7 +90,7 @@ public final class HSSFRichTextString implements Comparable<HSSFRichTextString>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HSSFRichTextString(Workbook book, LabelSSTRecord record) {
|
HSSFRichTextString(InternalWorkbook book, LabelSSTRecord record) {
|
||||||
setWorkbookReferences(book, record);
|
setWorkbookReferences(book, record);
|
||||||
|
|
||||||
_string = book.getSSTString(record.getSSTIndex());
|
_string = book.getSSTString(record.getSSTIndex());
|
||||||
|
@ -99,7 +99,7 @@ public final class HSSFRichTextString implements Comparable<HSSFRichTextString>,
|
||||||
/** This must be called to setup the internal work book references whenever
|
/** This must be called to setup the internal work book references whenever
|
||||||
* a RichTextString is added to a cell
|
* a RichTextString is added to a cell
|
||||||
*/
|
*/
|
||||||
void setWorkbookReferences(Workbook book, LabelSSTRecord record) {
|
void setWorkbookReferences(InternalWorkbook book, LabelSSTRecord record) {
|
||||||
_book = book;
|
_book = book;
|
||||||
_record = record;
|
_record = record;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import java.util.TreeMap;
|
||||||
|
|
||||||
import org.apache.poi.ddf.EscherRecord;
|
import org.apache.poi.ddf.EscherRecord;
|
||||||
import org.apache.poi.hssf.model.Sheet;
|
import org.apache.poi.hssf.model.Sheet;
|
||||||
import org.apache.poi.hssf.model.Workbook;
|
import org.apache.poi.hssf.model.InternalWorkbook;
|
||||||
import org.apache.poi.hssf.record.CellValueRecordInterface;
|
import org.apache.poi.hssf.record.CellValueRecordInterface;
|
||||||
import org.apache.poi.hssf.record.DVRecord;
|
import org.apache.poi.hssf.record.DVRecord;
|
||||||
import org.apache.poi.hssf.record.EscherAggregate;
|
import org.apache.poi.hssf.record.EscherAggregate;
|
||||||
|
@ -82,7 +82,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
||||||
private final Sheet _sheet;
|
private final Sheet _sheet;
|
||||||
/** stores rows by zero-based row number */
|
/** stores rows by zero-based row number */
|
||||||
private final TreeMap<Integer, HSSFRow> _rows;
|
private final TreeMap<Integer, HSSFRow> _rows;
|
||||||
protected final Workbook _book;
|
protected final InternalWorkbook _book;
|
||||||
protected final HSSFWorkbook _workbook;
|
protected final HSSFWorkbook _workbook;
|
||||||
private int _firstrow;
|
private int _firstrow;
|
||||||
private int _lastrow;
|
private int _lastrow;
|
||||||
|
@ -636,7 +636,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether the worksheet is displayed from right to left instead of from left to right.
|
* Sets whether the worksheet is displayed from right to left instead of from left to right.
|
||||||
*
|
*
|
||||||
* @param value true for right to left, false otherwise.
|
* @param value true for right to left, false otherwise.
|
||||||
*/
|
*/
|
||||||
public void setRightToLeft(boolean value)
|
public void setRightToLeft(boolean value)
|
||||||
|
@ -1693,7 +1693,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
||||||
|
|
||||||
FontRenderContext frc = new FontRenderContext(null, true, true);
|
FontRenderContext frc = new FontRenderContext(null, true, true);
|
||||||
|
|
||||||
HSSFWorkbook wb = new HSSFWorkbook(_book);
|
HSSFWorkbook wb = HSSFWorkbook.create(_book); // TODO - is it important to not use _workbook?
|
||||||
HSSFFont defaultFont = wb.getFontAt((short) 0);
|
HSSFFont defaultFont = wb.getFontAt((short) 0);
|
||||||
|
|
||||||
str = new AttributedString("" + defaultChar);
|
str = new AttributedString("" + defaultChar);
|
||||||
|
|
|
@ -38,7 +38,7 @@ import org.apache.poi.hssf.OldExcelFormatException;
|
||||||
import org.apache.poi.hssf.model.HSSFFormulaParser;
|
import org.apache.poi.hssf.model.HSSFFormulaParser;
|
||||||
import org.apache.poi.hssf.model.RecordStream;
|
import org.apache.poi.hssf.model.RecordStream;
|
||||||
import org.apache.poi.hssf.model.Sheet;
|
import org.apache.poi.hssf.model.Sheet;
|
||||||
import org.apache.poi.hssf.model.Workbook;
|
import org.apache.poi.hssf.model.InternalWorkbook;
|
||||||
import org.apache.poi.hssf.record.AbstractEscherHolderRecord;
|
import org.apache.poi.hssf.record.AbstractEscherHolderRecord;
|
||||||
import org.apache.poi.hssf.record.BackupRecord;
|
import org.apache.poi.hssf.record.BackupRecord;
|
||||||
import org.apache.poi.hssf.record.DrawingGroupRecord;
|
import org.apache.poi.hssf.record.DrawingGroupRecord;
|
||||||
|
@ -78,13 +78,13 @@ import org.apache.poi.util.POILogger;
|
||||||
* will construct whether they are reading or writing a workbook. It is also the
|
* will construct whether they are reading or writing a workbook. It is also the
|
||||||
* top level object for creating new sheets/etc.
|
* top level object for creating new sheets/etc.
|
||||||
*
|
*
|
||||||
* @see org.apache.poi.hssf.model.Workbook
|
* @see org.apache.poi.hssf.model.InternalWorkbook
|
||||||
* @see org.apache.poi.hssf.usermodel.HSSFSheet
|
* @see org.apache.poi.hssf.usermodel.HSSFSheet
|
||||||
* @author Andrew C. Oliver (acoliver at apache dot org)
|
* @author Andrew C. Oliver (acoliver at apache dot org)
|
||||||
* @author Glen Stampoultzis (glens at apache.org)
|
* @author Glen Stampoultzis (glens at apache.org)
|
||||||
* @author Shawn Laubach (slaubach at apache dot org)
|
* @author Shawn Laubach (slaubach at apache dot org)
|
||||||
*/
|
*/
|
||||||
public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.usermodel.Workbook {
|
public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.usermodel.Workbook {
|
||||||
private static final Pattern COMMA_PATTERN = Pattern.compile(",");
|
private static final Pattern COMMA_PATTERN = Pattern.compile(",");
|
||||||
private static final int MAX_ROW = 0xFFFF;
|
private static final int MAX_ROW = 0xFFFF;
|
||||||
private static final short MAX_COLUMN = (short)0x00FF;
|
private static final short MAX_COLUMN = (short)0x00FF;
|
||||||
|
@ -104,7 +104,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm
|
||||||
* this is the reference to the low level Workbook object
|
* this is the reference to the low level Workbook object
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private Workbook workbook;
|
private InternalWorkbook workbook;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this holds the HSSFSheet objects attached to this workbook
|
* this holds the HSSFSheet objects attached to this workbook
|
||||||
|
@ -162,25 +162,26 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm
|
||||||
|
|
||||||
private static POILogger log = POILogFactory.getLogger(HSSFWorkbook.class);
|
private static POILogger log = POILogFactory.getLogger(HSSFWorkbook.class);
|
||||||
|
|
||||||
|
public static HSSFWorkbook create(InternalWorkbook book) {
|
||||||
|
return new HSSFWorkbook(book);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Creates new HSSFWorkbook from scratch (start here!)
|
* Creates new HSSFWorkbook from scratch (start here!)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public HSSFWorkbook()
|
public HSSFWorkbook() {
|
||||||
{
|
this(InternalWorkbook.createWorkbook());
|
||||||
this(Workbook.createWorkbook());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected HSSFWorkbook( Workbook book )
|
private HSSFWorkbook(InternalWorkbook book) {
|
||||||
{
|
super(null, null);
|
||||||
super(null, null);
|
workbook = book;
|
||||||
workbook = book;
|
_sheets = new ArrayList(INITIAL_CAPACITY);
|
||||||
_sheets = new ArrayList( INITIAL_CAPACITY );
|
names = new ArrayList(INITIAL_CAPACITY);
|
||||||
names = new ArrayList( INITIAL_CAPACITY );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public HSSFWorkbook(POIFSFileSystem fs) throws IOException {
|
public HSSFWorkbook(POIFSFileSystem fs) throws IOException {
|
||||||
this(fs,true);
|
this(fs,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -275,7 +276,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm
|
||||||
|
|
||||||
List records = RecordFactory.createRecords(stream);
|
List records = RecordFactory.createRecords(stream);
|
||||||
|
|
||||||
workbook = Workbook.createWorkbook(records);
|
workbook = InternalWorkbook.createWorkbook(records);
|
||||||
setPropertiesFromWorkbook(workbook);
|
setPropertiesFromWorkbook(workbook);
|
||||||
int recOffset = workbook.getNumRecords();
|
int recOffset = workbook.getNumRecords();
|
||||||
int sheetNum = 0;
|
int sheetNum = 0;
|
||||||
|
@ -321,7 +322,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm
|
||||||
* used internally to set the workbook properties.
|
* used internally to set the workbook properties.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private void setPropertiesFromWorkbook(Workbook book)
|
private void setPropertiesFromWorkbook(InternalWorkbook book)
|
||||||
{
|
{
|
||||||
this.workbook = book;
|
this.workbook = book;
|
||||||
|
|
||||||
|
@ -1225,7 +1226,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm
|
||||||
* @return byte[] array containing the binary representation of this workbook and all contained
|
* @return byte[] array containing the binary representation of this workbook and all contained
|
||||||
* sheets, rows, cells, etc.
|
* sheets, rows, cells, etc.
|
||||||
*
|
*
|
||||||
* @see org.apache.poi.hssf.model.Workbook
|
* @see org.apache.poi.hssf.model.InternalWorkbook
|
||||||
* @see org.apache.poi.hssf.model.Sheet
|
* @see org.apache.poi.hssf.model.Sheet
|
||||||
*/
|
*/
|
||||||
public byte[] getBytes() {
|
public byte[] getBytes() {
|
||||||
|
@ -1290,8 +1291,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm
|
||||||
return workbook.getSSTString(index).getString();
|
return workbook.getSSTString(index).getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Workbook getWorkbook()
|
InternalWorkbook getWorkbook() {
|
||||||
{
|
|
||||||
return workbook;
|
return workbook;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ import junit.framework.TestCase;
|
||||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||||
import org.apache.poi.hssf.eventusermodel.EventWorkbookBuilder.SheetRecordCollectingListener;
|
import org.apache.poi.hssf.eventusermodel.EventWorkbookBuilder.SheetRecordCollectingListener;
|
||||||
import org.apache.poi.hssf.model.HSSFFormulaParser;
|
import org.apache.poi.hssf.model.HSSFFormulaParser;
|
||||||
import org.apache.poi.hssf.model.Workbook;
|
import org.apache.poi.hssf.model.InternalWorkbook;
|
||||||
import org.apache.poi.hssf.record.FormulaRecord;
|
import org.apache.poi.hssf.record.FormulaRecord;
|
||||||
import org.apache.poi.hssf.record.Record;
|
import org.apache.poi.hssf.record.Record;
|
||||||
import org.apache.poi.hssf.record.formula.Ptg;
|
import org.apache.poi.hssf.record.formula.Ptg;
|
||||||
|
@ -41,13 +41,13 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||||
public final class TestEventWorkbookBuilder extends TestCase {
|
public final class TestEventWorkbookBuilder extends TestCase {
|
||||||
private MockHSSFListener mockListen;
|
private MockHSSFListener mockListen;
|
||||||
private SheetRecordCollectingListener listener;
|
private SheetRecordCollectingListener listener;
|
||||||
|
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
HSSFRequest req = new HSSFRequest();
|
HSSFRequest req = new HSSFRequest();
|
||||||
mockListen = new MockHSSFListener();
|
mockListen = new MockHSSFListener();
|
||||||
listener = new SheetRecordCollectingListener(mockListen);
|
listener = new SheetRecordCollectingListener(mockListen);
|
||||||
req.addListenerForAllRecords(listener);
|
req.addListenerForAllRecords(listener);
|
||||||
|
|
||||||
HSSFEventFactory factory = new HSSFEventFactory();
|
HSSFEventFactory factory = new HSSFEventFactory();
|
||||||
try {
|
try {
|
||||||
InputStream is = HSSFTestDataSamples.openSampleFileStream("3dFormulas.xls");
|
InputStream is = HSSFTestDataSamples.openSampleFileStream("3dFormulas.xls");
|
||||||
|
@ -56,94 +56,94 @@ public final class TestEventWorkbookBuilder extends TestCase {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBasics() {
|
public void testBasics() {
|
||||||
assertNotNull(listener.getSSTRecord());
|
assertNotNull(listener.getSSTRecord());
|
||||||
assertNotNull(listener.getBoundSheetRecords());
|
assertNotNull(listener.getBoundSheetRecords());
|
||||||
assertNotNull(listener.getExternSheetRecords());
|
assertNotNull(listener.getExternSheetRecords());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetStubWorkbooks() {
|
public void testGetStubWorkbooks() {
|
||||||
assertNotNull(listener.getStubWorkbook());
|
assertNotNull(listener.getStubWorkbook());
|
||||||
assertNotNull(listener.getStubHSSFWorkbook());
|
assertNotNull(listener.getStubHSSFWorkbook());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testContents() {
|
public void testContents() {
|
||||||
assertEquals(2, listener.getSSTRecord().getNumStrings());
|
assertEquals(2, listener.getSSTRecord().getNumStrings());
|
||||||
assertEquals(3, listener.getBoundSheetRecords().length);
|
assertEquals(3, listener.getBoundSheetRecords().length);
|
||||||
assertEquals(1, listener.getExternSheetRecords().length);
|
assertEquals(1, listener.getExternSheetRecords().length);
|
||||||
|
|
||||||
assertEquals(3, listener.getStubWorkbook().getNumSheets());
|
assertEquals(3, listener.getStubWorkbook().getNumSheets());
|
||||||
|
|
||||||
Workbook ref = listener.getStubWorkbook();
|
InternalWorkbook ref = listener.getStubWorkbook();
|
||||||
assertEquals("Sh3", ref.findSheetNameFromExternSheet(0));
|
assertEquals("Sh3", ref.findSheetNameFromExternSheet(0));
|
||||||
assertEquals("Sheet1", ref.findSheetNameFromExternSheet(1));
|
assertEquals("Sheet1", ref.findSheetNameFromExternSheet(1));
|
||||||
assertEquals("S2", ref.findSheetNameFromExternSheet(2));
|
assertEquals("S2", ref.findSheetNameFromExternSheet(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFormulas() {
|
public void testFormulas() {
|
||||||
|
|
||||||
FormulaRecord[] fRecs = mockListen.getFormulaRecords();
|
FormulaRecord[] fRecs = mockListen.getFormulaRecords();
|
||||||
|
|
||||||
// Check our formula records
|
// Check our formula records
|
||||||
assertEquals(6, fRecs.length);
|
assertEquals(6, fRecs.length);
|
||||||
|
|
||||||
Workbook stubWB = listener.getStubWorkbook();
|
InternalWorkbook stubWB = listener.getStubWorkbook();
|
||||||
assertNotNull(stubWB);
|
assertNotNull(stubWB);
|
||||||
HSSFWorkbook stubHSSF = listener.getStubHSSFWorkbook();
|
HSSFWorkbook stubHSSF = listener.getStubHSSFWorkbook();
|
||||||
assertNotNull(stubHSSF);
|
assertNotNull(stubHSSF);
|
||||||
|
|
||||||
// Check these stubs have the right stuff on them
|
// Check these stubs have the right stuff on them
|
||||||
assertEquals("Sheet1", stubWB.getSheetName(0));
|
assertEquals("Sheet1", stubWB.getSheetName(0));
|
||||||
assertEquals("S2", stubWB.getSheetName(1));
|
assertEquals("S2", stubWB.getSheetName(1));
|
||||||
assertEquals("Sh3", stubWB.getSheetName(2));
|
assertEquals("Sh3", stubWB.getSheetName(2));
|
||||||
|
|
||||||
// Check we can get the formula without breaking
|
// Check we can get the formula without breaking
|
||||||
for(int i=0; i<fRecs.length; i++) {
|
for(int i=0; i<fRecs.length; i++) {
|
||||||
HSSFFormulaParser.toFormulaString(stubHSSF, fRecs[i].getParsedExpression());
|
HSSFFormulaParser.toFormulaString(stubHSSF, fRecs[i].getParsedExpression());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Peer into just one formula, and check that
|
// Peer into just one formula, and check that
|
||||||
// all the ptgs give back the right things
|
// all the ptgs give back the right things
|
||||||
Ptg[] ptgs = fRecs[0].getParsedExpression();
|
Ptg[] ptgs = fRecs[0].getParsedExpression();
|
||||||
assertEquals(1, ptgs.length);
|
assertEquals(1, ptgs.length);
|
||||||
assertTrue(ptgs[0] instanceof Ref3DPtg);
|
assertTrue(ptgs[0] instanceof Ref3DPtg);
|
||||||
|
|
||||||
Ref3DPtg ptg = (Ref3DPtg)ptgs[0];
|
Ref3DPtg ptg = (Ref3DPtg)ptgs[0];
|
||||||
HSSFEvaluationWorkbook book = HSSFEvaluationWorkbook.create(stubHSSF);
|
HSSFEvaluationWorkbook book = HSSFEvaluationWorkbook.create(stubHSSF);
|
||||||
assertEquals("Sheet1!A1", ptg.toFormulaString(book));
|
assertEquals("Sheet1!A1", ptg.toFormulaString(book));
|
||||||
|
|
||||||
|
|
||||||
// Now check we get the right formula back for
|
// Now check we get the right formula back for
|
||||||
// a few sample ones
|
// a few sample ones
|
||||||
FormulaRecord fr;
|
FormulaRecord fr;
|
||||||
|
|
||||||
// Sheet 1 A2 is on same sheet
|
// Sheet 1 A2 is on same sheet
|
||||||
fr = fRecs[0];
|
fr = fRecs[0];
|
||||||
assertEquals(1, fr.getRow());
|
assertEquals(1, fr.getRow());
|
||||||
assertEquals(0, fr.getColumn());
|
assertEquals(0, fr.getColumn());
|
||||||
assertEquals("Sheet1!A1", HSSFFormulaParser.toFormulaString(stubHSSF, fr.getParsedExpression()));
|
assertEquals("Sheet1!A1", HSSFFormulaParser.toFormulaString(stubHSSF, fr.getParsedExpression()));
|
||||||
|
|
||||||
// Sheet 1 A5 is to another sheet
|
// Sheet 1 A5 is to another sheet
|
||||||
fr = fRecs[3];
|
fr = fRecs[3];
|
||||||
assertEquals(4, fr.getRow());
|
assertEquals(4, fr.getRow());
|
||||||
assertEquals(0, fr.getColumn());
|
assertEquals(0, fr.getColumn());
|
||||||
assertEquals("'S2'!A1", HSSFFormulaParser.toFormulaString(stubHSSF, fr.getParsedExpression()));
|
assertEquals("'S2'!A1", HSSFFormulaParser.toFormulaString(stubHSSF, fr.getParsedExpression()));
|
||||||
|
|
||||||
// Sheet 1 A7 is to another sheet, range
|
// Sheet 1 A7 is to another sheet, range
|
||||||
fr = fRecs[5];
|
fr = fRecs[5];
|
||||||
assertEquals(6, fr.getRow());
|
assertEquals(6, fr.getRow());
|
||||||
assertEquals(0, fr.getColumn());
|
assertEquals(0, fr.getColumn());
|
||||||
assertEquals("SUM(Sh3!A1:A4)", HSSFFormulaParser.toFormulaString(stubHSSF, fr.getParsedExpression()));
|
assertEquals("SUM(Sh3!A1:A4)", HSSFFormulaParser.toFormulaString(stubHSSF, fr.getParsedExpression()));
|
||||||
|
|
||||||
|
|
||||||
// Now, load via Usermodel and re-check
|
// Now, load via Usermodel and re-check
|
||||||
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("3dFormulas.xls");
|
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("3dFormulas.xls");
|
||||||
assertEquals("Sheet1!A1", wb.getSheetAt(0).getRow(1).getCell(0).getCellFormula());
|
assertEquals("Sheet1!A1", wb.getSheetAt(0).getRow(1).getCell(0).getCellFormula());
|
||||||
assertEquals("SUM(Sh3!A1:A4)", wb.getSheetAt(0).getRow(6).getCell(0).getCellFormula());
|
assertEquals("SUM(Sh3!A1:A4)", wb.getSheetAt(0).getRow(6).getCell(0).getCellFormula());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class MockHSSFListener implements HSSFListener {
|
private static final class MockHSSFListener implements HSSFListener {
|
||||||
public MockHSSFListener() {}
|
public MockHSSFListener() {}
|
||||||
private final List _records = new ArrayList();
|
private final List _records = new ArrayList();
|
||||||
|
@ -161,4 +161,4 @@ public final class TestEventWorkbookBuilder extends TestCase {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,11 @@
|
||||||
|
|
||||||
package org.apache.poi.hssf.model;
|
package org.apache.poi.hssf.model;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.apache.poi.hssf.record.FontRecord;
|
import org.apache.poi.hssf.record.FontRecord;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
|
import org.apache.poi.hssf.usermodel.TestHSSFWorkbook;
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit test for the Workbook class.
|
* Unit test for the Workbook class.
|
||||||
|
@ -29,7 +30,7 @@ import junit.framework.TestCase;
|
||||||
*/
|
*/
|
||||||
public final class TestWorkbook extends TestCase {
|
public final class TestWorkbook extends TestCase {
|
||||||
public void testFontStuff() {
|
public void testFontStuff() {
|
||||||
Workbook wb = (new HW()).getWorkbook();
|
InternalWorkbook wb = TestHSSFWorkbook.getInternalWorkbook(new HSSFWorkbook());
|
||||||
|
|
||||||
assertEquals(4, wb.getNumberOfFontRecords());
|
assertEquals(4, wb.getNumberOfFontRecords());
|
||||||
assertEquals(68, wb.getRecords().size());
|
assertEquals(68, wb.getRecords().size());
|
||||||
|
@ -82,13 +83,4 @@ public final class TestWorkbook extends TestCase {
|
||||||
assertEquals(6, wb.getFontIndex(n7));
|
assertEquals(6, wb.getFontIndex(n7));
|
||||||
assertEquals(n7, wb.getFontRecordAt(6));
|
assertEquals(n7, wb.getFontRecordAt(6));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class HW extends HSSFWorkbook {
|
|
||||||
public HW() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
protected Workbook getWorkbook() {
|
|
||||||
return super.getWorkbook();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.poi.hssf.usermodel;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
import org.apache.poi.hssf.model.Sheet;
|
import org.apache.poi.hssf.model.Sheet;
|
||||||
import org.apache.poi.hssf.model.Workbook;
|
import org.apache.poi.hssf.model.InternalWorkbook;
|
||||||
import org.apache.poi.hssf.record.*;
|
import org.apache.poi.hssf.record.*;
|
||||||
import org.apache.poi.hssf.record.aggregates.PageSettingsBlock;
|
import org.apache.poi.hssf.record.aggregates.PageSettingsBlock;
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ public class SanityChecker
|
||||||
new CheckRecord(EOFRecord.class, '1')
|
new CheckRecord(EOFRecord.class, '1')
|
||||||
};
|
};
|
||||||
|
|
||||||
private void checkWorkbookRecords(Workbook workbook)
|
private void checkWorkbookRecords(InternalWorkbook workbook)
|
||||||
{
|
{
|
||||||
List records = workbook.getRecords();
|
List records = workbook.getRecords();
|
||||||
assertTrue(records.get(0) instanceof BOFRecord);
|
assertTrue(records.get(0) instanceof BOFRecord);
|
||||||
|
|
|
@ -31,7 +31,7 @@ import junit.framework.AssertionFailedError;
|
||||||
import org.apache.poi.hssf.HSSFITestDataProvider;
|
import org.apache.poi.hssf.HSSFITestDataProvider;
|
||||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||||
import org.apache.poi.hssf.OldExcelFormatException;
|
import org.apache.poi.hssf.OldExcelFormatException;
|
||||||
import org.apache.poi.hssf.model.Workbook;
|
import org.apache.poi.hssf.model.InternalWorkbook;
|
||||||
import org.apache.poi.hssf.record.CellValueRecordInterface;
|
import org.apache.poi.hssf.record.CellValueRecordInterface;
|
||||||
import org.apache.poi.hssf.record.EmbeddedObjectRefSubRecord;
|
import org.apache.poi.hssf.record.EmbeddedObjectRefSubRecord;
|
||||||
import org.apache.poi.hssf.record.NameRecord;
|
import org.apache.poi.hssf.record.NameRecord;
|
||||||
|
@ -171,7 +171,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||||
public void test15375_2() {
|
public void test15375_2() {
|
||||||
baseTest15375(6000);
|
baseTest15375(6000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Double byte strings*/
|
/**Double byte strings*/
|
||||||
public void test15556() {
|
public void test15556() {
|
||||||
|
|
||||||
|
@ -844,7 +844,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||||
|
|
||||||
// Check all names fit within range, and use
|
// Check all names fit within range, and use
|
||||||
// DeletedArea3DPtg
|
// DeletedArea3DPtg
|
||||||
Workbook w = wb.getWorkbook();
|
InternalWorkbook w = wb.getWorkbook();
|
||||||
for(int i=0; i<w.getNumNames(); i++) {
|
for(int i=0; i<w.getNumNames(); i++) {
|
||||||
NameRecord r = w.getNameRecord(i);
|
NameRecord r = w.getNameRecord(i);
|
||||||
assertTrue(r.getSheetNumber() <= wb.getNumberOfSheets());
|
assertTrue(r.getSheetNumber() <= wb.getNumberOfSheets());
|
||||||
|
@ -1249,7 +1249,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||||
/**
|
/**
|
||||||
* The resolution for bug 45777 assumed that the maximum text length in a header / footer
|
* The resolution for bug 45777 assumed that the maximum text length in a header / footer
|
||||||
* record was 256 bytes. This assumption appears to be wrong. Since the fix for bug 47244,
|
* record was 256 bytes. This assumption appears to be wrong. Since the fix for bug 47244,
|
||||||
* POI now supports header / footer text lengths beyond 256 bytes.
|
* POI now supports header / footer text lengths beyond 256 bytes.
|
||||||
*/
|
*/
|
||||||
public void test45777() {
|
public void test45777() {
|
||||||
HSSFWorkbook wb = new HSSFWorkbook();
|
HSSFWorkbook wb = new HSSFWorkbook();
|
||||||
|
@ -1375,7 +1375,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||||
HSSFWorkbook wb = openSample("45290.xls");
|
HSSFWorkbook wb = openSample("45290.xls");
|
||||||
assertEquals(1, wb.getNumberOfSheets());
|
assertEquals(1, wb.getNumberOfSheets());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In POI-2.5 user reported exception when parsing a name with a custom VBA function:
|
* In POI-2.5 user reported exception when parsing a name with a custom VBA function:
|
||||||
* =MY_VBA_FUNCTION("lskdjflsk")
|
* =MY_VBA_FUNCTION("lskdjflsk")
|
||||||
|
@ -1455,7 +1455,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||||
wb.write(out);
|
wb.write(out);
|
||||||
out.close();
|
out.close();
|
||||||
int size1 = out.size();
|
int size1 = out.size();
|
||||||
|
|
||||||
out = new ByteArrayOutputStream();
|
out = new ByteArrayOutputStream();
|
||||||
wb.write(out);
|
wb.write(out);
|
||||||
out.close();
|
out.close();
|
||||||
|
@ -1469,7 +1469,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||||
assertEquals(size2, size3);
|
assertEquals(size2, size3);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* java.io.IOException: block[ 0 ] already removed
|
* java.io.IOException: block[ 0 ] already removed
|
||||||
* (is an excel 95 file though)
|
* (is an excel 95 file though)
|
||||||
|
@ -1484,7 +1484,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* java.lang.NegativeArraySizeException reading long
|
* java.lang.NegativeArraySizeException reading long
|
||||||
* non-unicode data for a name record
|
* non-unicode data for a name record
|
||||||
|
@ -1514,7 +1514,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||||
*/
|
*/
|
||||||
public void test48180() {
|
public void test48180() {
|
||||||
HSSFWorkbook wb = openSample("48180.xls");
|
HSSFWorkbook wb = openSample("48180.xls");
|
||||||
|
|
||||||
HSSFSheet s = wb.getSheetAt(0);
|
HSSFSheet s = wb.getSheetAt(0);
|
||||||
HSSFCell cell1 = s.getRow(0).getCell(0);
|
HSSFCell cell1 = s.getRow(0).getCell(0);
|
||||||
assertEquals("test ", cell1.getStringCellValue().toString());
|
assertEquals("test ", cell1.getStringCellValue().toString());
|
||||||
|
@ -1524,12 +1524,12 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POI 3.5 beta 7 can not read excel file contain list box (Form Control)
|
* POI 3.5 beta 7 can not read excel file contain list box (Form Control)
|
||||||
*/
|
*/
|
||||||
public void test47701() {
|
public void test47701() {
|
||||||
openSample("47701.xls");
|
openSample("47701.xls");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void test48026() {
|
public void test48026() {
|
||||||
openSample("48026.xls");
|
openSample("48026.xls");
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.TimeZone;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||||
import org.apache.poi.hssf.model.Workbook;
|
import org.apache.poi.hssf.model.InternalWorkbook;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TestHSSFDateUtil
|
* Class TestHSSFDateUtil
|
||||||
|
@ -306,7 +306,7 @@ public final class TestHSSFDateUtil extends TestCase {
|
||||||
|
|
||||||
HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("DateFormats.xls");
|
HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("DateFormats.xls");
|
||||||
HSSFSheet sheet = workbook.getSheetAt(0);
|
HSSFSheet sheet = workbook.getSheetAt(0);
|
||||||
Workbook wb = workbook.getWorkbook();
|
InternalWorkbook wb = workbook.getWorkbook();
|
||||||
|
|
||||||
HSSFRow row;
|
HSSFRow row;
|
||||||
HSSFCell cell;
|
HSSFCell cell;
|
||||||
|
|
|
@ -25,6 +25,7 @@ import junit.framework.AssertionFailedError;
|
||||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||||
import org.apache.poi.hssf.HSSFITestDataProvider;
|
import org.apache.poi.hssf.HSSFITestDataProvider;
|
||||||
import org.apache.poi.hssf.model.HSSFFormulaParser;
|
import org.apache.poi.hssf.model.HSSFFormulaParser;
|
||||||
|
import org.apache.poi.hssf.model.InternalWorkbook;
|
||||||
import org.apache.poi.hssf.model.Sheet;
|
import org.apache.poi.hssf.model.Sheet;
|
||||||
import org.apache.poi.hssf.record.NameRecord;
|
import org.apache.poi.hssf.record.NameRecord;
|
||||||
import org.apache.poi.hssf.record.Record;
|
import org.apache.poi.hssf.record.Record;
|
||||||
|
@ -48,6 +49,13 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook {
|
||||||
return HSSFITestDataProvider.getInstance();
|
return HSSFITestDataProvider.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gives test code access to the {@link InternalWorkbook} within {@link HSSFWorkbook}
|
||||||
|
*/
|
||||||
|
public static InternalWorkbook getInternalWorkbook(HSSFWorkbook wb) {
|
||||||
|
return wb.getWorkbook();
|
||||||
|
}
|
||||||
|
|
||||||
public void testSetRepeatingRowsAndColumns() {
|
public void testSetRepeatingRowsAndColumns() {
|
||||||
// Test bug 29747
|
// Test bug 29747
|
||||||
HSSFWorkbook b = new HSSFWorkbook( );
|
HSSFWorkbook b = new HSSFWorkbook( );
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.io.IOException;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||||
import org.apache.poi.hssf.model.Workbook;
|
import org.apache.poi.hssf.model.InternalWorkbook;
|
||||||
import org.apache.poi.hssf.record.BackupRecord;
|
import org.apache.poi.hssf.record.BackupRecord;
|
||||||
import org.apache.poi.hssf.record.LabelSSTRecord;
|
import org.apache.poi.hssf.record.LabelSSTRecord;
|
||||||
import org.apache.poi.hssf.record.Record;
|
import org.apache.poi.hssf.record.Record;
|
||||||
|
@ -449,7 +449,7 @@ public final class TestWorkbook extends TestCase {
|
||||||
public void testBackupRecord() {
|
public void testBackupRecord() {
|
||||||
HSSFWorkbook wb = new HSSFWorkbook();
|
HSSFWorkbook wb = new HSSFWorkbook();
|
||||||
wb.createSheet();
|
wb.createSheet();
|
||||||
Workbook workbook = wb.getWorkbook();
|
InternalWorkbook workbook = wb.getWorkbook();
|
||||||
BackupRecord record = workbook.getBackupRecord();
|
BackupRecord record = workbook.getBackupRecord();
|
||||||
|
|
||||||
assertEquals(0, record.getBackup());
|
assertEquals(0, record.getBackup());
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
|
|
||||||
package org.apache.poi.hssf.util;
|
package org.apache.poi.hssf.util;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||||
import org.apache.poi.hssf.model.HSSFFormulaParser;
|
import org.apache.poi.hssf.model.HSSFFormulaParser;
|
||||||
import org.apache.poi.hssf.model.Workbook;
|
import org.apache.poi.hssf.model.InternalWorkbook;
|
||||||
import org.apache.poi.hssf.record.NameRecord;
|
import org.apache.poi.hssf.record.NameRecord;
|
||||||
import org.apache.poi.hssf.record.formula.Area3DPtg;
|
import org.apache.poi.hssf.record.formula.Area3DPtg;
|
||||||
import org.apache.poi.hssf.record.formula.MemFuncPtg;
|
import org.apache.poi.hssf.record.formula.MemFuncPtg;
|
||||||
|
@ -36,10 +35,11 @@ import org.apache.poi.hssf.usermodel.HSSFName;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
|
import org.apache.poi.hssf.usermodel.TestHSSFWorkbook;
|
||||||
import org.apache.poi.ss.util.AreaReference;
|
import org.apache.poi.ss.util.AreaReference;
|
||||||
import org.apache.poi.ss.util.CellReference;
|
import org.apache.poi.ss.util.CellReference;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public final class TestAreaReference extends TestCase {
|
public final class TestAreaReference extends TestCase {
|
||||||
|
|
||||||
|
@ -52,54 +52,54 @@ public final class TestAreaReference extends TestCase {
|
||||||
assertTrue("row is abs",cf.isRowAbsolute());
|
assertTrue("row is abs",cf.isRowAbsolute());
|
||||||
assertTrue("col is abs",cf.isColAbsolute());
|
assertTrue("col is abs",cf.isColAbsolute());
|
||||||
assertTrue("string is $A$1",cf.formatAsString().equals("$A$1"));
|
assertTrue("string is $A$1",cf.formatAsString().equals("$A$1"));
|
||||||
|
|
||||||
cf = ar.getLastCell();
|
cf = ar.getLastCell();
|
||||||
assertTrue("row is 4",cf.getRow()==1);
|
assertTrue("row is 4",cf.getRow()==1);
|
||||||
assertTrue("col is 1",cf.getCol()==1);
|
assertTrue("col is 1",cf.getCol()==1);
|
||||||
assertTrue("row is abs",cf.isRowAbsolute());
|
assertTrue("row is abs",cf.isRowAbsolute());
|
||||||
assertTrue("col is abs",cf.isColAbsolute());
|
assertTrue("col is abs",cf.isColAbsolute());
|
||||||
assertTrue("string is $B$2",cf.formatAsString().equals("$B$2"));
|
assertTrue("string is $B$2",cf.formatAsString().equals("$B$2"));
|
||||||
|
|
||||||
CellReference[] refs = ar.getAllReferencedCells();
|
CellReference[] refs = ar.getAllReferencedCells();
|
||||||
assertEquals(4, refs.length);
|
assertEquals(4, refs.length);
|
||||||
|
|
||||||
assertEquals(0, refs[0].getRow());
|
assertEquals(0, refs[0].getRow());
|
||||||
assertEquals(0, refs[0].getCol());
|
assertEquals(0, refs[0].getCol());
|
||||||
assertNull(refs[0].getSheetName());
|
assertNull(refs[0].getSheetName());
|
||||||
|
|
||||||
assertEquals(0, refs[1].getRow());
|
assertEquals(0, refs[1].getRow());
|
||||||
assertEquals(1, refs[1].getCol());
|
assertEquals(1, refs[1].getCol());
|
||||||
assertNull(refs[1].getSheetName());
|
assertNull(refs[1].getSheetName());
|
||||||
|
|
||||||
assertEquals(1, refs[2].getRow());
|
assertEquals(1, refs[2].getRow());
|
||||||
assertEquals(0, refs[2].getCol());
|
assertEquals(0, refs[2].getCol());
|
||||||
assertNull(refs[2].getSheetName());
|
assertNull(refs[2].getSheetName());
|
||||||
|
|
||||||
assertEquals(1, refs[3].getRow());
|
assertEquals(1, refs[3].getRow());
|
||||||
assertEquals(1, refs[3].getCol());
|
assertEquals(1, refs[3].getCol());
|
||||||
assertNull(refs[3].getSheetName());
|
assertNull(refs[3].getSheetName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* References failed when sheet names were being used
|
* References failed when sheet names were being used
|
||||||
* Reported by Arne.Clauss@gedas.de
|
* Reported by Arne.Clauss@gedas.de
|
||||||
*/
|
*/
|
||||||
public void testReferenceWithSheet() {
|
public void testReferenceWithSheet() {
|
||||||
AreaReference ar;
|
AreaReference ar;
|
||||||
|
|
||||||
ar = new AreaReference("Tabelle1!B5:B5");
|
ar = new AreaReference("Tabelle1!B5:B5");
|
||||||
assertTrue(ar.isSingleCell());
|
assertTrue(ar.isSingleCell());
|
||||||
TestCellReference.confirmCell(ar.getFirstCell(), "Tabelle1", 4, 1, false, false, "Tabelle1!B5");
|
TestCellReference.confirmCell(ar.getFirstCell(), "Tabelle1", 4, 1, false, false, "Tabelle1!B5");
|
||||||
|
|
||||||
assertEquals(1, ar.getAllReferencedCells().length);
|
assertEquals(1, ar.getAllReferencedCells().length);
|
||||||
|
|
||||||
|
|
||||||
ar = new AreaReference("Tabelle1!$B$5:$B$7");
|
ar = new AreaReference("Tabelle1!$B$5:$B$7");
|
||||||
assertFalse(ar.isSingleCell());
|
assertFalse(ar.isSingleCell());
|
||||||
|
|
||||||
TestCellReference.confirmCell(ar.getFirstCell(), "Tabelle1", 4, 1, true, true, "Tabelle1!$B$5");
|
TestCellReference.confirmCell(ar.getFirstCell(), "Tabelle1", 4, 1, true, true, "Tabelle1!$B$5");
|
||||||
TestCellReference.confirmCell(ar.getLastCell(), "Tabelle1", 6, 1, true, true, "Tabelle1!$B$7");
|
TestCellReference.confirmCell(ar.getLastCell(), "Tabelle1", 6, 1, true, true, "Tabelle1!$B$7");
|
||||||
|
|
||||||
// And all that make it up
|
// And all that make it up
|
||||||
CellReference[] allCells = ar.getAllReferencedCells();
|
CellReference[] allCells = ar.getAllReferencedCells();
|
||||||
assertEquals(3, allCells.length);
|
assertEquals(3, allCells.length);
|
||||||
|
@ -108,16 +108,6 @@ public final class TestAreaReference extends TestCase {
|
||||||
TestCellReference.confirmCell(allCells[2], "Tabelle1", 6, 1, true, true, "Tabelle1!$B$7");
|
TestCellReference.confirmCell(allCells[2], "Tabelle1", 6, 1, true, true, "Tabelle1!$B$7");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO - remove this sub-class
|
|
||||||
private static final class HSSFWB extends HSSFWorkbook {
|
|
||||||
public HSSFWB(InputStream in) throws IOException {
|
|
||||||
super(in);
|
|
||||||
}
|
|
||||||
public Workbook getWorkbook() {
|
|
||||||
return super.getWorkbook();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testContiguousReferences() {
|
public void testContiguousReferences() {
|
||||||
String refSimple = "$C$10:$C$10";
|
String refSimple = "$C$10:$C$10";
|
||||||
String ref2D = "$C$10:$D$11";
|
String ref2D = "$C$10:$D$11";
|
||||||
|
@ -138,15 +128,21 @@ public final class TestAreaReference extends TestCase {
|
||||||
try {
|
try {
|
||||||
new AreaReference(refDCSimple);
|
new AreaReference(refDCSimple);
|
||||||
fail();
|
fail();
|
||||||
} catch(IllegalArgumentException e) {}
|
} catch(IllegalArgumentException e) {
|
||||||
|
// expected during successful test
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
new AreaReference(refDC2D);
|
new AreaReference(refDC2D);
|
||||||
fail();
|
fail();
|
||||||
} catch(IllegalArgumentException e) {}
|
} catch(IllegalArgumentException e) {
|
||||||
|
// expected during successful test
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
new AreaReference(refDC3D);
|
new AreaReference(refDC3D);
|
||||||
fail();
|
fail();
|
||||||
} catch(IllegalArgumentException e) {}
|
} catch(IllegalArgumentException e) {
|
||||||
|
// expected during successful test
|
||||||
|
}
|
||||||
|
|
||||||
// Test that we split as expected
|
// Test that we split as expected
|
||||||
AreaReference[] refs;
|
AreaReference[] refs;
|
||||||
|
@ -193,8 +189,8 @@ public final class TestAreaReference extends TestCase {
|
||||||
|
|
||||||
public void testDiscontinousReference() throws Exception {
|
public void testDiscontinousReference() throws Exception {
|
||||||
InputStream is = HSSFTestDataSamples.openSampleFileStream("44167.xls");
|
InputStream is = HSSFTestDataSamples.openSampleFileStream("44167.xls");
|
||||||
HSSFWB wb = new HSSFWB(is);
|
HSSFWorkbook wb = new HSSFWorkbook(is);
|
||||||
Workbook workbook = wb.getWorkbook();
|
InternalWorkbook workbook = TestHSSFWorkbook.getInternalWorkbook(wb);
|
||||||
HSSFEvaluationWorkbook eb = HSSFEvaluationWorkbook.create(wb);
|
HSSFEvaluationWorkbook eb = HSSFEvaluationWorkbook.create(wb);
|
||||||
|
|
||||||
assertEquals(1, wb.getNumberOfNames());
|
assertEquals(1, wb.getNumberOfNames());
|
||||||
|
@ -252,18 +248,18 @@ public final class TestAreaReference extends TestCase {
|
||||||
HSSFCell c = r.getCell((int)cref.getCol());
|
HSSFCell c = r.getCell((int)cref.getCol());
|
||||||
assertNotNull(c);
|
assertNotNull(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSpecialSheetNames() {
|
public void testSpecialSheetNames() {
|
||||||
AreaReference ar;
|
AreaReference ar;
|
||||||
ar = new AreaReference("'Sheet A'!A1:A1");
|
ar = new AreaReference("'Sheet A'!A1:A1");
|
||||||
confirmAreaSheetName(ar, "Sheet A", "'Sheet A'!A1");
|
confirmAreaSheetName(ar, "Sheet A", "'Sheet A'!A1");
|
||||||
|
|
||||||
ar = new AreaReference("'Hey! Look Here!'!A1:A1");
|
ar = new AreaReference("'Hey! Look Here!'!A1:A1");
|
||||||
confirmAreaSheetName(ar, "Hey! Look Here!", "'Hey! Look Here!'!A1");
|
confirmAreaSheetName(ar, "Hey! Look Here!", "'Hey! Look Here!'!A1");
|
||||||
|
|
||||||
ar = new AreaReference("'O''Toole'!A1:B2");
|
ar = new AreaReference("'O''Toole'!A1:B2");
|
||||||
confirmAreaSheetName(ar, "O'Toole", "'O''Toole'!A1:B2");
|
confirmAreaSheetName(ar, "O'Toole", "'O''Toole'!A1:B2");
|
||||||
|
|
||||||
ar = new AreaReference("'one:many'!A1:B2");
|
ar = new AreaReference("'one:many'!A1:B2");
|
||||||
confirmAreaSheetName(ar, "one:many", "'one:many'!A1:B2");
|
confirmAreaSheetName(ar, "one:many", "'one:many'!A1:B2");
|
||||||
}
|
}
|
||||||
|
@ -273,25 +269,24 @@ public final class TestAreaReference extends TestCase {
|
||||||
assertEquals(sheetName, cells[0].getSheetName());
|
assertEquals(sheetName, cells[0].getSheetName());
|
||||||
assertEquals(expectedFullText, ar.formatAsString());
|
assertEquals(expectedFullText, ar.formatAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWholeColumnRefs() {
|
public void testWholeColumnRefs() {
|
||||||
confirmWholeColumnRef("A:A", 0, 0, false, false);
|
confirmWholeColumnRef("A:A", 0, 0, false, false);
|
||||||
confirmWholeColumnRef("$C:D", 2, 3, true, false);
|
confirmWholeColumnRef("$C:D", 2, 3, true, false);
|
||||||
confirmWholeColumnRef("AD:$AE", 29, 30, false, true);
|
confirmWholeColumnRef("AD:$AE", 29, 30, false, true);
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static void confirmWholeColumnRef(String ref, int firstCol, int lastCol, boolean firstIsAbs, boolean lastIsAbs) {
|
private static void confirmWholeColumnRef(String ref, int firstCol, int lastCol, boolean firstIsAbs, boolean lastIsAbs) {
|
||||||
AreaReference ar = new AreaReference(ref);
|
AreaReference ar = new AreaReference(ref);
|
||||||
confirmCell(ar.getFirstCell(), 0, firstCol, true, firstIsAbs);
|
confirmCell(ar.getFirstCell(), 0, firstCol, true, firstIsAbs);
|
||||||
confirmCell(ar.getLastCell(), 0xFFFF, lastCol, true, lastIsAbs);
|
confirmCell(ar.getLastCell(), 0xFFFF, lastCol, true, lastIsAbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void confirmCell(CellReference cell, int row, int col, boolean isRowAbs,
|
private static void confirmCell(CellReference cell, int row, int col, boolean isRowAbs,
|
||||||
boolean isColAbs) {
|
boolean isColAbs) {
|
||||||
assertEquals(row, cell.getRow());
|
assertEquals(row, cell.getRow());
|
||||||
assertEquals(col, cell.getCol());
|
assertEquals(col, cell.getCol());
|
||||||
assertEquals(isRowAbs, cell.isRowAbsolute());
|
assertEquals(isRowAbs, cell.isRowAbsolute());
|
||||||
assertEquals(isColAbs, cell.isColAbsolute());
|
assertEquals(isColAbs, cell.isColAbsolute());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue