minor changes - initial work on bugzilla 48292 (support for array formulas)

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@885006 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2009-11-27 20:54:03 +00:00
parent 97a5bf3d61
commit c73dd9d324
5 changed files with 726 additions and 712 deletions

View File

@ -32,6 +32,9 @@ public abstract class SharedValueRecordBase extends StandardRecord {
private CellRangeAddress8Bit _range;
protected SharedValueRecordBase(CellRangeAddress8Bit range) {
if (range == null) {
throw new IllegalArgumentException("range must be supplied.");
}
_range = range;
}
@ -46,6 +49,9 @@ public abstract class SharedValueRecordBase extends StandardRecord {
_range = new CellRangeAddress8Bit(in);
}
/**
* @return the range of cells that this record is shared across. Never <code>null</code>.
*/
public final CellRangeAddress8Bit getRange() {
return _range;
}

View File

@ -30,41 +30,42 @@ import org.apache.poi.util.LittleEndianOutput;
public final class ExpPtg extends ControlPtg {
private final static int SIZE = 5;
public final static short sid = 0x1;
private final short field_1_first_row;
private final short field_2_first_col;
private final int field_1_first_row;
private final int field_2_first_col;
public ExpPtg(LittleEndianInput in)
{
public ExpPtg(LittleEndianInput in) {
field_1_first_row = in.readShort();
field_2_first_col = in.readShort();
}
public ExpPtg(int firstRow, int firstCol) {
this.field_1_first_row = firstRow;
this.field_2_first_col = firstCol;
}
public void write(LittleEndianOutput out) {
out.writeByte(sid + getPtgClass());
out.writeShort(field_1_first_row);
out.writeShort(field_2_first_col);
}
public int getSize()
{
public int getSize() {
return SIZE;
}
public short getRow() {
public int getRow() {
return field_1_first_row;
}
public short getColumn() {
public int getColumn() {
return field_2_first_col;
}
public String toFormulaString()
{
public String toFormulaString() {
throw new RecordFormatException("Coding Error: Expected ExpPtg to be converted from Shared to Non-Shared Formula by ValueRecordsAggregate, but it wasn't");
}
public String toString()
{
public String toString() {
StringBuffer buffer = new StringBuffer("[Array Formula or Shared Formula]\n");
buffer.append("row = ").append(getRow()).append("\n");
buffer.append("col = ").append(getColumn()).append("\n");

View File

@ -18,6 +18,7 @@
package org.apache.poi.ss.util;
import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.usermodel.Cell;
/**
@ -111,6 +112,11 @@ public abstract class CellRangeAddressBase {
return _lastRow;
}
public boolean isInRange(int rowInd, int colInd) {
return _firstRow <= rowInd && rowInd <= _lastRow &&
_firstCol <= colInd && colInd <= _lastCol;
}
/**
* @param firstCol column number for the upper left hand corner
*/

View File

@ -888,7 +888,7 @@ public final class XSSFCell implements Cell {
int sstIndex = Integer.parseInt(_cell.getV());
XSSFRichTextString rt = new XSSFRichTextString(_sharedStringSource.getEntryAt(sstIndex));
String text = rt.getString();
return Boolean.valueOf(text);
return Boolean.parseBoolean(text);
case CELL_TYPE_NUMERIC:
return Double.parseDouble(_cell.getV()) != 0;

View File

@ -39,6 +39,7 @@ import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Footer;
import org.apache.poi.ss.usermodel.Header;