package org.apache.poi.examples.hssf.eventusermodel;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
*/
@SuppressWarnings({"java:S106","java:S4823"})
public class XLS2CSVmra implements HSSFListener {
- private int minColumns;
- private POIFSFileSystem fs;
- private PrintStream output;
+ private final int minColumns;
+ private final POIFSFileSystem fs;
+ private final PrintStream output;
private int lastRowNumber;
private int lastColumnNumber;
/** Should we output the formula, or the value it has? */
- private boolean outputFormulaValues = true;
+ private final boolean outputFormulaValues = true;
/** For parsing Formulas */
private SheetRecordCollectingListener workbookBuildingListener;
/** So we known which sheet we're on */
private int sheetIndex = -1;
private BoundSheetRecord[] orderedBSRs;
- private List<BoundSheetRecord> boundSheetRecords = new ArrayList<>();
+ private final List<BoundSheetRecord> boundSheetRecords = new ArrayList<>();
// For handling formulas with string results
private int nextRow;
* @param filename The file to process
* @param minColumns The minimum number of columns to output, or -1 for no minimum
*/
- public XLS2CSVmra(String filename, int minColumns) throws IOException, FileNotFoundException {
+ public XLS2CSVmra(String filename, int minColumns) throws IOException {
this(
new POIFSFileSystem(new FileInputStream(filename)),
System.out, minColumns
/** whether 1904 date windowing is being used */
private boolean uses1904datewindowing;
private DrawingManager2 drawingManager;
- private List<EscherBSERecord> escherBSERecords;
+ private final List<EscherBSERecord> escherBSERecords;
private WindowOneRecord windowOne;
private FileSharingRecord fileShare;
private WriteAccessRecord writeAccess;
logObj = "format";
FormatRecord fr = (FormatRecord) rec;
retval.formats.add(fr);
- retval.maxformatid = retval.maxformatid >= fr.getIndexCode() ? retval.maxformatid : fr.getIndexCode();
+ retval.maxformatid = Math.max(retval.maxformatid, fr.getIndexCode());
break;
case DateWindow1904Record.sid :
// set up format records
for (int i = 0; i <= 7; i++) {
FormatRecord rec = createFormat(i);
- retval.maxformatid = retval.maxformatid >= rec.getIndexCode() ? retval.maxformatid : rec.getIndexCode();
+ retval.maxformatid = Math.max(retval.maxformatid, rec.getIndexCode());
formats.add(rec);
records.add(rec);
}
}
pos += len;
}
-
+
LOG.log( DEBUG, "Exiting serialize workbook" );
return pos;
}
drawingManager = findDrawingManager(dg, escherBSERecords);
return drawingManager;
}
-
+
private static DrawingManager2 findDrawingManager(DrawingGroupRecord dg, List<EscherBSERecord> escherBSERecords) {
if (dg == null) {
return null;
if(dgg == null) {
return null;
}
-
+
DrawingManager2 dm = new DrawingManager2(dgg);
if(bStore != null){
for(EscherRecord bs : bStore.getChildRecords()){
if(aggLoc == -1) {
return;
}
-
+
EscherAggregate agg = (EscherAggregate) sheet.findFirstRecordBySid(EscherAggregate.sid);
EscherContainerRecord escherContainer = agg.getEscherContainer();
if (escherContainer == null) {
import org.apache.poi.hssf.record.CountryRecord;
import org.apache.poi.hssf.record.FontRecord;
import org.apache.poi.hssf.record.RecalcIdRecord;
+import org.apache.poi.hssf.record.WriteAccessRecord;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.TestHSSFWorkbook;
-import org.apache.poi.ss.formula.OperationEvaluationContext;
-import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.FreeRefFunction;
import org.apache.poi.ss.formula.udf.AggregatingUDFFinder;
import org.apache.poi.ss.formula.udf.DefaultUDFFinder;
InternalWorkbook wb = TestHSSFWorkbook.getInternalWorkbook(hwb);
assertNotNull(wb.getNameXPtg("ISODD", AggregatingUDFFinder.DEFAULT));
- FreeRefFunction NotImplemented = new FreeRefFunction() {
- @Override
- public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
- throw new RuntimeException("not implemented");
- }
+ FreeRefFunction NotImplemented = (args, ec) -> {
+ throw new RuntimeException("not implemented");
};
/*
wb.setForceFormulaRecalculation(true); // resets the EngineId flag to zero
assertEquals(0, record.getEngineId());
assertFalse(wb.getForceFormulaRecalculation());
-
+
wb.close();
}
}