if (num < 0) {
throw new IllegalArgumentException("Maximum Number of Data Formats must be greater than or equal to 0");
} else {
- throw new IllegalStateException("Cannot set the maximum number of data formats less than the current quantity." +
+ throw new IllegalStateException("Cannot set the maximum number of data formats less than the current quantity. " +
"Data formats must be explicitly removed (via StylesTable.removeNumberFormat) before the limit can be decreased.");
}
}
short nextKey = (short) (numberFormats.lastKey() + 1);
if (nextKey < 0) {
throw new IllegalStateException(
- "Cowardly avoiding creating a number format with a negative id." +
+ "Cowardly avoiding creating a number format with a negative id. " +
"This is probably due to arithmetic overflow.");
}
formatIndex = (short) Math.max(nextKey, FIRST_USER_DEFINED_NUMBER_FORMAT_ID);
return cell.getCellFormula(fpb);
}
}
- if (f.getT() == STCellFormulaType.SHARED) {
+ if (f == null) {
+ return null;
+ } else if (f.getT() == STCellFormulaType.SHARED) {
return convertSharedFormula((int)f.getSi(), fpb == null ? XSSFEvaluationWorkbook.create(getSheet().getWorkbook()) : fpb);
+ } else {
+ return f.getStringValue();
}
- return f.getStringValue();
}
/**
package org.apache.poi.xssf.usermodel;
import org.apache.poi.ss.usermodel.ClientAnchor;
-import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType;
import org.apache.poi.util.Internal;
import org.apache.poi.util.Units;
import org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D;
// this.cell2 = calcCell(sheet, cell1, size.getCx(), size.getCy());
}
- /**
- *
- * @param sheet
- * @param cell starting point and offsets (may be zeros)
- * @param size dimensions to calculate relative to starting point
- */
private CTMarker calcCell(CTMarker cell, long w, long h) {
CTMarker c2 = CTMarker.Factory.newInstance();
// we potentially need to adjust the column/row information in the shape
// the same way as we do in setRow()/setColumn()
- if(vmlShape != null && vmlShape.sizeOfClientDataArray() > 0) {
+ if(comment != null && vmlShape != null && vmlShape.sizeOfClientDataArray() > 0) {
CellReference ref = new CellReference(comment.getRef());
CTClientData clientData = vmlShape.getClientDataArray(0);
clientData.setRowArray(0, new BigInteger(String.valueOf(ref.getRow())));
*/
@Override
public String getAuthor() {
- return _comments.getAuthor((int) _comment.getAuthorId());
+ return _comments.getAuthor(_comment.getAuthorId());
}
/**
*/
@Override
public void setAuthor(String author) {
- _comment.setAuthorId(
- _comments.findAuthor(author)
- );
+ _comment.setAuthorId(_comments.findAuthor(author));
}
/**
}
}
- private void unsetCollapsed(boolean collapsed, CTCol ci) {
- if (collapsed) {
+ private void unsetCollapsed(Boolean collapsed, CTCol ci) {
+ if (collapsed != null && collapsed.booleanValue()) {
ci.setCollapsed(collapsed);
} else {
ci.unsetCollapsed();
boolean endHidden = false;
int endOfOutlineGroupIdx = findEndOfColumnOutlineGroup(idx);
CTCol[] colArray = cols.getColArray();
- if (endOfOutlineGroupIdx < colArray.length) {
+ if (endOfOutlineGroupIdx < (colArray.length - 1)) {
CTCol nextInfo = colArray[endOfOutlineGroupIdx + 1];
if (isAdjacentBefore(colArray[endOfOutlineGroupIdx], nextInfo)) {
endLevel = nextInfo.getOutlineLevel();
// "Got srcRows[" + (index-1) + "]=Row " + prevRow.getRowNum() + ", srcRows[" + index + "]=Row " + curRow.getRowNum() + ".");
// FIXME: assumes row objects belong to non-null sheets and sheets belong to non-null workbooks.
} else if (srcStartRow.getSheet().getWorkbook() != curRow.getSheet().getWorkbook()) {
- throw new IllegalArgumentException("All rows in srcRows must belong to the same sheet in the same workbook." +
+ throw new IllegalArgumentException("All rows in srcRows must belong to the same sheet in the same workbook. " +
"Expected all rows from same workbook (" + srcStartRow.getSheet().getWorkbook() + "). " +
"Got srcRows[" + index + "] from different workbook (" + curRow.getSheet().getWorkbook() + ").");
} else if (srcStartRow.getSheet() != curRow.getSheet()) {