protected EvaluationWorkbook getEvaluationWorkbook() {
return _bookEvaluator.getWorkbook();
}
-
+
/**
* Should be called whenever there are major changes (e.g. moving sheets) to input cells
* in the evaluated workbook. If performance is not critical, a single call to this method
throw new IllegalStateException("Bad cell type (" + cell.getCellType() + ")");
}
}
-
+
/**
* If cell contains formula, it evaluates the formula, and
* puts the formula result back into the cell, in place
}
/**
- * set the cell type
- * @param cell
- * @param cv
+ * Set the cell type based on the computed cell type as
+ * part of a formula evaluation.
+ *
+ * @param cell The Cell to populate
+ * @param cv The CellValue to read the result type from
*/
protected void setCellType(Cell cell, CellValue cv) {
CellType cellType = cv.getCellType();
/**
* Override if a different variation is needed, e.g. passing the evaluator to the cell method
- * @param cell
- * @param cellType
+ *
+ * @param cell The Cell to populate
+ * @param cellType The wanted type for this Cell
*/
protected void setCellType(Cell cell, CellType cellType) {
+ //noinspection deprecation
cell.setCellType(cellType);
}
-
+
protected abstract RichTextString createRichTextString(String str);
-
+
protected void setCellValue(Cell cell, CellValue cv) {
CellType cellType = cv.getCellType();
switch (cellType) {
throw new IllegalStateException("Unexpected cell value type (" + cellType + ")");
}
}
-
+
/**
* Loops over all cells in all sheets of the supplied
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.util.Internal;
-import org.apache.poi.util.Removal;
/**
super(pkg);
init(pkg);
}
-
+
protected POIXMLDocument(OPCPackage pkg, String coreDocumentRel) {
super(pkg, coreDocumentRel);
init(pkg);
}
-
+
private void init(OPCPackage p) {
this.pkg = p;
-
+
// Workaround for XMLBEANS-512 - ensure that when we parse
// the file, we start with a fresh XML Parser each time,
// and avoid the risk of getting a SaxHandler that's in error
/**
* Wrapper to open a package, which works around shortcomings in java's this() constructor calls
- *
+ *
* @param path the path to the document
* @return the new OPCPackage
- *
+ *
* @exception IOException if there was a problem opening the document
*/
public static OPCPackage openPackage(String path) throws IOException {
/**
* Retrieves all the PackageParts which are defined as relationships of the base document with the
* specified content type.
- *
+ *
* @param contentType the content type
- *
+ *
* @return all the base document PackageParts which match the content type
- *
+ *
* @throws InvalidFormatException when the relationships or the parts contain errors
- *
+ *
* @see org.apache.poi.xssf.usermodel.XSSFRelation
* @see org.apache.poi.xslf.usermodel.XSLFRelation
* @see org.apache.poi.xwpf.usermodel.XWPFRelation
/**
* Get the document properties. This gives you access to the
* core ooxml properties, and the extended ooxml properties.
- *
+ *
* @return the document properties
*/
public POIXMLProperties getProperties() {
onDocumentRead();
context.clear();
}
-
+
/**
* Closes the underlying {@link OPCPackage} from which this
* document was read, if there is one
}
/**
- * Write out this document to an Outputstream.
+ * Write out this document to an {@link OutputStream}.
*
* Note - if the Document was opened from a {@link File} rather
* than an {@link InputStream}, you <b>must</b> write out to
* a different file, overwriting via an OutputStream isn't possible.
- *
+ *
* If {@code stream} is a {@link java.io.FileOutputStream} on a networked drive
* or has a high cost/latency associated with each written byte,
* consider wrapping the OutputStream in a {@link java.io.BufferedOutputStream}
* to improve write performance.
- *
+ *
* @param stream - the java OutputStream you wish to write the file to
*
* @exception IOException if anything can't be written.
if(p == null) {
throw new IOException("Cannot write data, document seems to have been closed already");
}
-
+
//force all children to commit their changes into the underlying OOXML Package
// TODO Shouldn't they be committing to the new one instead?
Set<PackagePart> context = new HashSet<>();
private String coreDocumentRel = PackageRelationshipTypes.CORE_DOCUMENT;
private PackagePart packagePart;
private POIXMLDocumentPart parent;
- private Map<String, RelationPart> relations = new LinkedHashMap<>();
+ private final Map<String, RelationPart> relations = new LinkedHashMap<>();
private boolean isCommitted = false;
/**
* <p>
* If there are multiple relationships to the same part, this will only
* remove the first relationship in the order of creation. The removal
- * via the part id ({@link #removeRelation(String)} is preferred.
+ * via the part id ({@link #removeRelation(POIXMLDocumentPart)} is preferred.
*
* @param partId the part id which relation is to be removed from this document
* @since 4.0.0
* @return true, if the relation was removed
* @since 4.0.0
*/
- private final boolean removeRelation(String partId, boolean removeUnusedParts) {
+ private boolean removeRelation(String partId, boolean removeUnusedParts) {
RelationPart rp = relations.get(partId);
if (rp == null) {
// part is not related with this POIXMLDocumentPart
* Delete a part from the package
*
* @throws IllegalArgumentException
- * Throws if the part URI is nulll or invalid.
+ * Throws if the part URI is null or invalid.
*/
@Override
protected void removePartImpl(PackagePartName partName) {
* calls to evaluate~ methods on this class.
*/
public final class XSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator {
- private XSSFWorkbook _book;
+ private final XSSFWorkbook _book;
public XSSFFormulaEvaluator(XSSFWorkbook workbook) {
this(workbook, null, null);
public static void evaluateAllFormulaCells(XSSFWorkbook wb) {
BaseFormulaEvaluator.evaluateAllFormulaCells(wb);
}
-
+
@Override
public XSSFCell evaluateInCell(Cell cell) {
return (XSSFCell) super.evaluateInCell(cell);
}
-
+
/**
* Loops over all cells in all sheets of the supplied
* workbook.
* The locator of user-defined functions.
* By default includes functions from the Excel Analysis Toolpack
*/
- private IndexedUDFFinder _udfFinder = new IndexedUDFFinder(AggregatingUDFFinder.DEFAULT);
+ private final IndexedUDFFinder _udfFinder = new IndexedUDFFinder(AggregatingUDFFinder.DEFAULT);
/**
* TODO
*/
private List<XSSFPictureData> pictures;
- private static POILogger logger = POILogFactory.getLogger(XSSFWorkbook.class);
+ private static final POILogger logger = POILogFactory.getLogger(XSSFWorkbook.class);
/**
* cached instance of XSSFCreationHelper for this workbook
// Load individual sheets. The order of sheets is defined by the order
// of CTSheet elements in the workbook
sheets = new ArrayList<>(shIdMap.size());
- //noinspection deprecation
for (CTSheet ctSheet : this.workbook.getSheets().getSheetArray()) {
parseSheet(shIdMap, ctSheet);
}
newcts.set(cts);
//notify sheets
- //noinspection deprecation
CTSheet[] sheetArray = ct.getSheetArray();
for(int i=0; i < sheetArray.length; i++) {
sheets.get(i).sheet = sheetArray[i];
* @return true if the sheet contains the name, false otherwise.
*/
private boolean containsSheet(String name, int excludeSheetIdx) {
- //noinspection deprecation
CTSheet[] ctSheetArray = workbook.getSheets().getSheetArray();
if (name.length() > MAX_SENSITIVE_SHEET_NAME_LEN) {