Java Examples for org.apache.poi.xssf.streaming.SXSSFWorkbook
The following java examples will help you to understand the usage of org.apache.poi.xssf.streaming.SXSSFWorkbook. These source code samples are taken from different open source projects.
Example 1
| Project: poi-master File: TestXSSFSheet.java View source code |
private void runGetTopRow(String file, boolean isXSSF, int... topRows) throws IOException {
final Workbook wb = (isXSSF) ? XSSFTestDataSamples.openSampleWorkbook(file) : HSSFTestDataSamples.openSampleWorkbook(file);
for (int si = 0; si < wb.getNumberOfSheets(); si++) {
Sheet sh = wb.getSheetAt(si);
assertNotNull(sh.getSheetName());
assertEquals("Did not match for sheet " + si, topRows[si], sh.getTopRow());
}
// for XSSF also test with SXSSF
if (isXSSF) {
Workbook swb = new SXSSFWorkbook((XSSFWorkbook) wb);
for (int si = 0; si < swb.getNumberOfSheets(); si++) {
Sheet sh = swb.getSheetAt(si);
assertNotNull(sh.getSheetName());
assertEquals("Did not match for sheet " + si, topRows[si], sh.getTopRow());
}
swb.close();
}
wb.close();
}Example 2
| Project: jsr352-master File: ExcelUserModelItemWriter.java View source code |
@Override
public void open(final Serializable checkpoint) throws Exception {
//if template is used, create workbook based on template resource, and try to get header from template
if (templateResource != null) {
InputStream templateInputStream = null;
try {
templateInputStream = getInputStream(templateResource, false);
//for SXSSF (streaming), the original templateWorkbook is wrapped inside this.workbook, and these 2
// workbook instances are different. For XSSF and HSSF, the two are the same.
// SXSSF workbook does not support reading, so we have to use the original templateWorkbook to read
// header, and then reassign sheet to that of this.workbook, which is SXSSFWorkbook
final Workbook templateWorkbook = createWorkbook(templateInputStream);
if (templateSheetName != null) {
sheet = templateWorkbook.getSheet(templateSheetName);
}
if (sheet == null) {
sheet = templateWorkbook.getSheetAt(templateSheetIndex);
}
//if header property is already injected from job.xml, use it and no need to check templateHeaderRow
if (header == null) {
if (templateHeaderRow == null) {
throw SupportMessages.MESSAGES.invalidReaderWriterProperty(null, null, "templateHeaderRow");
}
final Row headerRow = sheet.getRow(templateHeaderRow);
if (headerRow == null) {
throw SupportMessages.MESSAGES.failToReadExcelHeader(templateResource, templateSheetName);
}
header = getCellStringValues(headerRow);
}
currentRowNum = sheet.getLastRowNum();
if (workbook != templateWorkbook) {
sheet = workbook.getSheet(sheet.getSheetName());
}
workbook.setActiveSheet(workbook.getSheetIndex(sheet));
} finally {
if (templateInputStream != null) {
try {
templateInputStream.close();
} catch (final Exception e) {
SupportLogger.LOGGER.tracef(e, "Failed to close template InputStream %s for template resource %s%n", templateInputStream, templateResource);
}
}
}
} else {
// no template is specified
createWorkbook(null);
sheet = sheetName == null ? workbook.createSheet() : workbook.createSheet(WorkbookUtil.createSafeSheetName(sheetName));
if (header == null) {
throw SupportMessages.MESSAGES.invalidReaderWriterProperty(null, null, "header");
}
//write header row
final Row headerRow = sheet.createRow(0);
for (int i = 0, j = header.length; i < j; ++i) {
headerRow.createCell(i, Cell.CELL_TYPE_STRING).setCellValue(header[i]);
}
currentRowNum = 0;
}
outputStream = getOutputStream(writeMode);
}Example 3
| Project: olca-modules-master File: ExcelExport.java View source code |
private void export(Process process) throws Exception {
Workbook workbook = new SXSSFWorkbook();
Config config = new Config(workbook, database, process);
writeSheets(config);
String fileName = process.getRefId() + "_" + Version.asString(process.getVersion()) + ".xlsx";
File file = new File(dir, fileName);
try (FileOutputStream fos = new FileOutputStream(file)) {
workbook.write(fos);
}
}Example 4
| Project: PoiParser-master File: AbstractPoiParserFactory.java View source code |
protected Workbook createNewWorkBook(PoiType poiType) {
if (null == poiType)
poiType = PoiType.HSSF;
final Workbook workBook;
switch(poiType) {
case XSSF:
workBook = new XSSFWorkbook();
break;
case SXSSF:
workBook = new SXSSFWorkbook();
break;
default:
workBook = new HSSFWorkbook();
break;
}
return workBook;
}Example 5
| Project: ExcelKit-master File: ExcelKit.java View source code |
@Override
public CellStyle headCellStyle(SXSSFWorkbook wb) {
CellStyle cellStyle = wb.createCellStyle();
Font font = wb.createFont();
cellStyle.setFillForegroundColor((short) 12);
// 填充模�
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
// 上边框为细边框
cellStyle.setBorderTop(CellStyle.BORDER_THIN);
// �边框为细边框
cellStyle.setBorderRight(CellStyle.BORDER_THIN);
// 下边框为细边框
cellStyle.setBorderBottom(CellStyle.BORDER_THIN);
// 左边框为细边框
cellStyle.setBorderLeft(CellStyle.BORDER_THIN);
cellStyle.setAlignment(// 对�
CellStyle.ALIGN_LEFT);
cellStyle.setFillForegroundColor(HSSFColor.GREEN.index);
cellStyle.setFillBackgroundColor(HSSFColor.GREEN.index);
font.setBoldweight(Font.BOLDWEIGHT_NORMAL);
// font.setFontHeightInPoints((short) 12);// å—体大å°?
font.setColor(HSSFColor.WHITE.index);
// åº”ç”¨æ ‡é¢˜å—ä½“åˆ°æ ‡é¢˜æ ·å¼?
cellStyle.setFont(font);
return cellStyle;
}Example 6
| Project: funiture-master File: TestExcel.java View source code |
public static void readAndCopyExcel() throws Exception {
/**
* 如果�测试该case, 请先在项目首层(pom.xml相�路径)放置一个test.xlsx文件
* 或者改这里的xlsx文件指定�置的文件
*/
String newFile = "temp.xlsx";
String originFile = "test.xlsx";
Workbook writeWorkbook = new SXSSFWorkbook();
Sheet writeSheet = writeWorkbook.createSheet();
// 将指定的excel读å?–到内å˜å¯¹è±¡ä¸
Workbook readWorkBook = new XSSFWorkbook(new FileInputStream(originFile));
// 读�excel第一个sheet
Sheet readSheet = readWorkBook.getSheetAt(0);
log.info("excel rows : {}", readSheet.getLastRowNum());
for (int index = 0; index < readSheet.getLastRowNum(); index++) {
// é??历excelçš„æ¯?行
try {
// æ ¹æ?®è¡Œå?·å?–出excelçš„æ¯?一行
Row readRow = readSheet.getRow(index);
if (readRow == null) {
break;
}
Iterator<Cell> cellIterator = readRow.cellIterator();
// 在新的excelæ–‡ä»¶ä¸æ·»åŠ ä¸€è¡Œ
Row writeRow = writeSheet.createRow(index);
int temp = 0;
while (cellIterator.hasNext()) {
// è¿ä»£é??历excelæ¯?行的æ¯?一列
//
Cell curCell = cellIterator.next();
if (temp == 0 && curCell == null) {
// 处ç?†å?¯èƒ½å˜åœ¨çš„è„?æ•°æ?®,这里å?‡è®¾ç¬¬ä¸€åˆ—为行å?·
break;
}
// 在新excel的当å‰?è¡Œä¸æ·»åŠ ä¸€ä¸ªcell
Cell writeRowCell = writeRow.createCell(temp);
writeRowCell.setCellType(curCell.getCellType());
switch(curCell.getCellType()) {
case Cell.CELL_TYPE_NUMERIC:
writeRowCell.setCellValue(curCell.getNumericCellValue());
break;
case Cell.CELL_TYPE_BOOLEAN:
writeRowCell.setCellValue(curCell.getBooleanCellValue());
break;
default:
writeRowCell.setCellValue(curCell.getStringCellValue());
}
temp++;
}
} catch (Exception e) {
log.error("parse excel exception, row: {}", index, e);
throw e;
}
}
log.info("generate new excel");
FileOutputStream newExcel = new FileOutputStream(newFile);
try {
writeWorkbook.write(newExcel);
} finally {
newExcel.flush();
newExcel.close();
}
}Example 7
| Project: jena-examples-master File: ExampleARQ_06.java View source code |
public static void main(String[] args) throws IOException {
FileManager.get().addLocatorClassLoader(ExampleARQ_01.class.getClassLoader());
Model model = FileManager.get().loadModel("data/data.ttl");
Query query = QueryFactory.create("SELECT * WHERE { ?s ?p ?o }");
QueryExecution qexec = QueryExecutionFactory.create(query, model);
FileOutputStream out = new FileOutputStream("target/sxssf.xlsx");
Workbook wb = new SXSSFWorkbook(100);
Sheet sh = wb.createSheet();
int rows = 0;
int columns = 0;
try {
ResultSet resultSet = qexec.execSelect();
List<String> varNames = resultSet.getResultVars();
List<Var> vars = new ArrayList<Var>(varNames.size());
// first row with var names
Row row = sh.createRow(rows++);
for (String varName : varNames) {
Var var = Var.alloc(varName);
Cell cell = row.createCell(columns++);
cell.setCellValue(var.toString());
vars.add(var);
}
// other rows with bindings
while (resultSet.hasNext()) {
Binding bindings = resultSet.nextBinding();
row = sh.createRow(rows++);
columns = 0;
for (Var var : vars) {
Node n = bindings.get(var);
if (n != null) {
Cell cell = row.createCell(columns++);
String value = FmtUtils.stringForNode(n, (SerializationContext) null);
cell.setCellValue(value);
}
}
}
} finally {
qexec.close();
}
wb.write(out);
out.close();
}Example 8
| Project: owsi-core-parent-master File: AbstractExcelExportAjaxSubmitLink.java View source code |
protected MediaType getMediaType(Workbook workbook) {
if (workbook instanceof HSSFWorkbook) {
return MediaType.APPLICATION_MS_EXCEL;
} else if (workbook instanceof XSSFWorkbook) {
return MediaType.APPLICATION_OPENXML_EXCEL;
} else if (workbook instanceof SXSSFWorkbook) {
return MediaType.APPLICATION_OPENXML_EXCEL;
} else {
// Default
return MediaType.APPLICATION_MS_EXCEL;
}
}Example 9
| Project: pentaho-kettle-master File: ExcelWriterStep.java View source code |
public void prepareNextOutputFile() throws KettleException {
try {
// sheet name shouldn't exceed 31 character
if (data.realSheetname != null && data.realSheetname.length() > 31) {
throw new KettleException(BaseMessages.getString(PKG, "ExcelWriterStep.Exception.MaxSheetName", data.realSheetname));
}
// clear style cache
int numOfFields = meta.getOutputFields() != null && meta.getOutputFields().length > 0 ? meta.getOutputFields().length : 0;
if (numOfFields == 0) {
numOfFields = data.inputRowMeta != null ? data.inputRowMeta.size() : 0;
}
data.clearStyleCache(numOfFields);
// build new filename
String buildFilename = buildFilename(data.splitnr);
data.file = KettleVFS.getFileObject(buildFilename, getTransMeta());
if (log.isDebug()) {
logDebug(BaseMessages.getString(PKG, "ExcelWriterStep.Log.OpeningFile", buildFilename));
}
// determine whether existing file must be deleted
if (data.file.exists() && data.createNewFile) {
if (!data.file.delete()) {
if (log.isBasic()) {
logBasic(BaseMessages.getString(PKG, "ExcelWriterStep.Log.CouldNotDeleteStaleFile", buildFilename));
}
setErrors(1);
throw new KettleException("Could not delete stale file " + buildFilename);
}
}
// adding filename to result
if (meta.isAddToResultFiles()) {
// Add this to the result file names...
ResultFile resultFile = new ResultFile(ResultFile.FILE_TYPE_GENERAL, data.file, getTransMeta().getName(), getStepname());
resultFile.setComment("This file was created with an Excel writer step by Pentaho Data Integration");
addResultFile(resultFile);
}
boolean appendingToSheet = true;
// if now no file exists we must create it as indicated by user
if (!data.file.exists()) {
// if template file is enabled
if (meta.isTemplateEnabled()) {
// handle template case (must have same format)
// ensure extensions match
String templateExt = KettleVFS.getFileObject(data.realTemplateFileName).getName().getExtension();
if (!meta.getExtension().equalsIgnoreCase(templateExt)) {
throw new KettleException("Template Format Mismatch: Template has extension: " + templateExt + ", but output file has extension: " + meta.getExtension() + ". Template and output file must share the same format!");
}
if (KettleVFS.getFileObject(data.realTemplateFileName).exists()) {
// if the template exists just copy the template in place
copyFile(KettleVFS.getFileObject(data.realTemplateFileName, getTransMeta()), data.file);
} else {
// template is missing, log it and get out
if (log.isBasic()) {
logBasic(BaseMessages.getString(PKG, "ExcelWriterStep.Log.TemplateMissing", data.realTemplateFileName));
}
setErrors(1);
throw new KettleException("Template file missing: " + data.realTemplateFileName);
}
} else {
// handle fresh file case, just create a fresh workbook
Workbook wb = meta.getExtension().equalsIgnoreCase("xlsx") ? new XSSFWorkbook() : new HSSFWorkbook();
BufferedOutputStreamWithCloseDetection out = new BufferedOutputStreamWithCloseDetection(KettleVFS.getOutputStream(data.file, false));
wb.createSheet(data.realSheetname);
wb.write(out);
out.close();
}
appendingToSheet = false;
}
// file is guaranteed to be in place now
if (meta.getExtension().equalsIgnoreCase("xlsx")) {
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(KettleVFS.getInputStream(data.file));
if (meta.isStreamingData()) {
data.wb = new SXSSFWorkbook(xssfWorkbook, 100);
} else {
data.wb = xssfWorkbook;
}
} else {
data.wb = new HSSFWorkbook(KettleVFS.getInputStream(data.file));
}
int existingActiveSheetIndex = data.wb.getActiveSheetIndex();
int replacingSheetAt = -1;
if (data.wb.getSheet(data.realSheetname) != null) {
// sheet exists, replace or reuse as indicated by user
if (data.createNewSheet) {
replacingSheetAt = data.wb.getSheetIndex(data.wb.getSheet(data.realSheetname));
data.wb.removeSheetAt(replacingSheetAt);
}
}
// if sheet is now missing, we need to create a new one
if (data.wb.getSheet(data.realSheetname) == null) {
if (meta.isTemplateSheetEnabled()) {
Sheet ts = data.wb.getSheet(data.realTemplateSheetName);
// if template sheet is missing, break
if (ts == null) {
throw new KettleException(BaseMessages.getString(PKG, "ExcelWriterStep.Exception.TemplateNotFound", data.realTemplateSheetName));
}
data.sheet = data.wb.cloneSheet(data.wb.getSheetIndex(ts));
data.wb.setSheetName(data.wb.getSheetIndex(data.sheet), data.realSheetname);
// unhide sheet in case it was hidden
data.wb.setSheetHidden(data.wb.getSheetIndex(data.sheet), false);
if (meta.isTemplateSheetHidden()) {
data.wb.setSheetHidden(data.wb.getSheetIndex(ts), true);
}
} else {
// no template to use, simply create a new sheet
data.sheet = data.wb.createSheet(data.realSheetname);
}
if (replacingSheetAt > -1) {
data.wb.setSheetOrder(data.sheet.getSheetName(), replacingSheetAt);
}
// preserves active sheet selection in workbook
data.wb.setActiveSheet(existingActiveSheetIndex);
data.wb.setSelectedTab(existingActiveSheetIndex);
appendingToSheet = false;
} else {
// sheet is there and should be reused
data.sheet = data.wb.getSheet(data.realSheetname);
}
// if use chose to make the current sheet active, do so
if (meta.isMakeSheetActive()) {
int sheetIndex = data.wb.getSheetIndex(data.sheet);
data.wb.setActiveSheet(sheetIndex);
data.wb.setSelectedTab(sheetIndex);
}
// handle write protection
if (meta.isSheetProtected()) {
protectSheet(data.sheet, data.realPassword);
}
// starting cell support
data.startingRow = 0;
data.startingCol = 0;
if (!Utils.isEmpty(data.realStartingCell)) {
CellReference cellRef = new CellReference(data.realStartingCell);
data.startingRow = cellRef.getRow();
data.startingCol = cellRef.getCol();
}
data.posX = data.startingCol;
data.posY = data.startingRow;
// Find last row and append accordingly
if (!data.createNewSheet && meta.isAppendLines() && appendingToSheet) {
data.posY = 0;
if (data.sheet.getPhysicalNumberOfRows() > 0) {
data.posY = data.sheet.getLastRowNum();
data.posY++;
}
}
// Find last row and append accordingly
if (!data.createNewSheet && meta.getAppendOffset() != 0 && appendingToSheet) {
data.posY += meta.getAppendOffset();
}
// may have to write a few empty lines
if (!data.createNewSheet && meta.getAppendEmpty() > 0 && appendingToSheet) {
for (int i = 0; i < meta.getAppendEmpty(); i++) {
openLine();
if (!data.shiftExistingCells || meta.isAppendLines()) {
data.posY++;
}
}
}
// may have to write a header here
if (meta.isHeaderEnabled() && !(!data.createNewSheet && meta.isAppendOmitHeader() && appendingToSheet)) {
writeHeader();
}
if (log.isDebug()) {
logDebug(BaseMessages.getString(PKG, "ExcelWriterStep.Log.FileOpened", buildFilename));
}
// this is the number of the new output file
data.splitnr++;
} catch (Exception e) {
logError("Error opening new file", e);
setErrors(1);
throw new KettleException(e);
}
}Example 10
| Project: Crud2Go-master File: ExcelExportTask.java View source code |
@Override
protected TableExport createExport() {
SXSSFWorkbook wkbk = new SXSSFWorkbook(50);
wkbk.setCompressTempFiles(true);
ExcelExportWithProgress excelExport = new ExcelExportWithProgress(vaadinTable, wkbk, "ExportCallback", null, getFilename(), false);
excelExport.setExportWindow("_blank");
excelExport.setMimeType(EXCEL_XSLX_MIMETYPE);
excelExport.setRowHeaders(true);
excelExport.excludeCollapsedColumns();
applyExcelFormatForColumns(excelExport);
return excelExport;
}Example 11
| Project: idnadrev-master File: ReflectionColumn.java View source code |
@Override
public CellStyle getCellStyle(SXSSFWorkbook workbook) {
CreationHelper creationHelper = workbook.getCreationHelper();
if (LocalDateTime.class.isAssignableFrom(fieldType)) {
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setDataFormat(creationHelper.createDataFormat().getFormat("yyyy/mm/dd hh:mm:ss"));
return cellStyle;
} else if (LocalDate.class.isAssignableFrom(fieldType)) {
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setDataFormat(creationHelper.createDataFormat().getFormat("yyyy/mm/dd"));
return cellStyle;
}
return null;
}Example 12
| Project: dbeaver-master File: DataExporterXLSX.java View source code |
@Override
public void init(IStreamDataExporterSite site) throws DBException {
Object nullStringProp = site.getProperties().get(PROP_NULL_STRING);
nullString = nullStringProp == null ? null : nullStringProp.toString();
try {
printHeader = (Boolean) site.getProperties().get(PROP_HEADER);
} catch (Exception e) {
printHeader = false;
}
try {
rowNumber = (Boolean) site.getProperties().get(PROP_ROWNUMBER);
} catch (Exception e) {
rowNumber = false;
}
try {
boolTrue = (String) site.getProperties().get(PROP_TRUESTRING);
} catch (Exception e) {
boolTrue = "YES";
}
try {
boolFalse = (String) site.getProperties().get(PROP_FALSESTRING);
} catch (Exception e) {
boolTrue = "NO";
}
wb = new SXSSFWorkbook(ROW_WINDOW);
sh = wb.createSheet();
rowIndex = 0;
styleHeader = (XSSFCellStyle) wb.createCellStyle();
BorderStyle border;
try {
border = BorderStyle.valueOf((String) site.getProperties().get(PROP_BORDER));
} catch (Exception e) {
border = BorderStyle.NONE;
}
FontStyleProp fontStyle;
try {
fontStyle = FontStyleProp.valueOf((String) site.getProperties().get(PROP_HEADER_FONT));
} catch (Exception e) {
fontStyle = FontStyleProp.NONE;
}
styleHeader.setBorderTop(border);
styleHeader.setBorderBottom(border);
styleHeader.setBorderLeft(border);
styleHeader.setBorderRight(border);
XSSFFont fontBold = (XSSFFont) wb.createFont();
switch(fontStyle) {
case BOLD:
fontBold.setBold(true);
break;
case ITALIC:
fontBold.setItalic(true);
break;
case STRIKEOUT:
fontBold.setStrikeout(true);
break;
case UNDERLINE:
fontBold.setUnderline((byte) 3);
break;
default:
break;
}
styleHeader.setFont(fontBold);
style = (XSSFCellStyle) wb.createCellStyle();
style.setBorderTop(border);
style.setBorderBottom(border);
style.setBorderLeft(border);
style.setBorderRight(border);
super.init(site);
}Example 13
| Project: metamodel-master File: ExcelUtils.java View source code |
public static Workbook readWorkbook(Resource resource) {
if (!resource.isExists()) {
// resource does not exist- create a blank workbook
if (isXlsxFile(resource)) {
return new SXSSFWorkbook(1000);
} else {
return new HSSFWorkbook();
}
}
if (resource instanceof FileResource) {
final File file = ((FileResource) resource).getFile();
try {
return WorkbookFactory.create(file);
} catch (Exception e) {
logger.error("Could not open workbook", e);
throw new IllegalStateException("Could not open workbook", e);
}
}
return resource.read(new Func<InputStream, Workbook>() {
@Override
public Workbook eval(InputStream inputStream) {
try {
return WorkbookFactory.create(inputStream);
} catch (Exception e) {
logger.error("Could not open workbook", e);
throw new IllegalStateException("Could not open workbook", e);
}
}
});
}Example 14
| Project: Raildelays-master File: ExcelRowAggregatorTest.java View source code |
/**
* We expect that if we use a {@link Workbook} sub-type which is not supported we do not aggregate the row.
* We should not throw any Exception.
*/
@Test
public void testInvalidFormatException() throws Exception {
workbook = new SXSSFWorkbook();
row = workbook.createSheet().createRow(ROW_INDEX);
initRow(row);
Assert.assertNotNull(aggregator.aggregate(item, workbook, SHEET_INDEX, ROW_INDEX));
Row row = workbook.getSheetAt(SHEET_INDEX).getRow(ROW_INDEX);
Assert.assertNotNull(row);
Assert.assertNotEquals(DELAY, row.getCell(54).getNumericCellValue());
}Example 15
| Project: sqlsheet-master File: XlsDriver.java View source code |
private SXSSFWorkbook getOrCreateXlsxStream(URL workbookUrl) throws IOException, InvalidFormatException { if (workbookUrl.getProtocol().equalsIgnoreCase("file")) { File source = new File(workbookUrl.getPath()); if (source.exists() || (source.length() != 0)) { logger.warning("File " + source.getPath() + " is not empty, and will parsed to memory!"); } else { Workbook workbook = new XSSFWorkbook(); flushWorkbook(workbook, source); } } return new SXSSFWorkbook(new XSSFWorkbook(workbookUrl.openStream()), 1000, false); }
Example 16
| Project: tika-master File: Report.java View source code |
private void dumpXLSX(Connection c, Path reportsRoot) throws IOException, SQLException {
Statement st = c.createStatement();
Path out = reportsRoot.resolve(reportFilename);
Files.createDirectories(out.getParent());
SXSSFWorkbook wb = new SXSSFWorkbook(new XSSFWorkbook(), 100, true, true);
wb.setCompressTempFiles(true);
defaultIntegerFormatter.reset(wb.getXSSFWorkbook());
defaultDoubleFormatter.reset(wb.getXSSFWorkbook());
sqlCellStyle = wb.createCellStyle();
sqlCellStyle.setVerticalAlignment(VerticalAlignment.TOP);
sqlCellStyle.setWrapText(true);
try {
dumpReportToWorkbook(st, wb);
} finally {
try (OutputStream os = Files.newOutputStream(out)) {
wb.write(os);
} finally {
wb.dispose();
}
}
}Example 17
| Project: Bam-master File: DataSetExportServicesImpl.java View source code |
@Override
public org.uberfire.backend.vfs.Path exportDataSetExcel(DataSet dataSet) {
try {
// TODO?: Excel 2010 limits: 1,048,576 rows by 16,384 columns; row width 255 characters
if (dataSet == null) {
throw new IllegalArgumentException("Null dataSet specified!");
}
int columnCount = dataSet.getColumns().size();
//Include header row;
int rowCount = dataSet.getRowCount() + 1;
int row = 0;
// keep 100 rows in memory, exceeding rows will be flushed to disk
SXSSFWorkbook wb = new SXSSFWorkbook(100);
Map<String, CellStyle> styles = createStyles(wb);
SXSSFSheet sh = wb.createSheet("Sheet 1");
// General setup
sh.setDisplayGridlines(true);
sh.setPrintGridlines(false);
sh.setFitToPage(true);
sh.setHorizontallyCenter(true);
sh.trackAllColumnsForAutoSizing();
PrintSetup printSetup = sh.getPrintSetup();
printSetup.setLandscape(true);
// Create header
Row header = sh.createRow(row++);
header.setHeightInPoints(20f);
for (int i = 0; i < columnCount; i++) {
Cell cell = header.createCell(i);
cell.setCellStyle(styles.get("header"));
cell.setCellValue(dataSet.getColumnByIndex(i).getId());
}
// Create data rows
for (; row < rowCount; row++) {
Row _row = sh.createRow(row);
for (int cellnum = 0; cellnum < columnCount; cellnum++) {
Cell cell = _row.createCell(cellnum);
Object value = dataSet.getValueAt(row - 1, cellnum);
if (value instanceof Short || value instanceof Long || value instanceof Integer || value instanceof BigInteger) {
cell.setCellType(CellType.NUMERIC);
cell.setCellStyle(styles.get("integer_number_cell"));
cell.setCellValue(((Number) value).doubleValue());
} else if (value instanceof Float || value instanceof Double || value instanceof BigDecimal) {
cell.setCellType(CellType.NUMERIC);
cell.setCellStyle(styles.get("decimal_number_cell"));
cell.setCellValue(((Number) value).doubleValue());
} else if (value instanceof Date) {
cell.setCellType(CellType.STRING);
cell.setCellStyle(styles.get("date_cell"));
cell.setCellValue((Date) value);
} else if (value instanceof Interval) {
cell.setCellType(CellType.STRING);
cell.setCellStyle(styles.get(TEXT_CELL));
cell.setCellValue(((Interval) value).getName());
} else {
cell.setCellType(CellType.STRING);
cell.setCellStyle(styles.get(TEXT_CELL));
cell.setCellValue(value.toString());
}
}
}
// Adjust column size
for (int i = 0; i < columnCount; i++) {
sh.autoSizeColumn(i);
}
String tempXlsFile = uuidGenerator.newUuid() + ".xlsx";
Path tempXlsPath = gitStorage.createTempFile(tempXlsFile);
OutputStream os = Files.newOutputStream(tempXlsPath);
wb.write(os);
os.flush();
os.close();
// Dispose of temporary files backing this workbook on disk
if (!wb.dispose()) {
log.warn("Could not dispose of temporary file associated to data export!");
}
return Paths.convert(tempXlsPath);
} catch (Exception e) {
throw exceptionManager.handleException(e);
}
}Example 18
| Project: dashbuilder-master File: DataSetExportServicesImpl.java View source code |
@Override
public org.uberfire.backend.vfs.Path exportDataSetExcel(DataSet dataSet) {
try {
// TODO?: Excel 2010 limits: 1,048,576 rows by 16,384 columns; row width 255 characters
if (dataSet == null)
throw new IllegalArgumentException("Null dataSet specified!");
int columnCount = dataSet.getColumns().size();
//Include header row;
int rowCount = dataSet.getRowCount() + 1;
int row = 0;
// keep 100 rows in memory, exceeding rows will be flushed to disk
SXSSFWorkbook wb = new SXSSFWorkbook(100);
Map<String, CellStyle> styles = createStyles(wb);
Sheet sh = wb.createSheet("Sheet 1");
// General setup
sh.setDisplayGridlines(true);
sh.setPrintGridlines(false);
sh.setFitToPage(true);
sh.setHorizontallyCenter(true);
PrintSetup printSetup = sh.getPrintSetup();
printSetup.setLandscape(true);
// Create header
Row header = sh.createRow(row++);
header.setHeightInPoints(20f);
for (int i = 0; i < columnCount; i++) {
Cell cell = header.createCell(i);
cell.setCellStyle(styles.get("header"));
cell.setCellValue(dataSet.getColumnByIndex(i).getId());
}
// Create data rows
for (; row < rowCount; row++) {
Row _row = sh.createRow(row);
for (int cellnum = 0; cellnum < columnCount; cellnum++) {
Cell cell = _row.createCell(cellnum);
Object value = dataSet.getValueAt(row - 1, cellnum);
if (value instanceof Short || value instanceof Long || value instanceof Integer || value instanceof BigInteger) {
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
cell.setCellStyle(styles.get("integer_number_cell"));
cell.setCellValue(((Number) value).doubleValue());
} else if (value instanceof Float || value instanceof Double || value instanceof BigDecimal) {
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
cell.setCellStyle(styles.get("decimal_number_cell"));
cell.setCellValue(((Number) value).doubleValue());
} else if (value instanceof Date) {
cell.setCellType(Cell.CELL_TYPE_STRING);
cell.setCellStyle(styles.get("date_cell"));
cell.setCellValue((Date) value);
} else if (value instanceof Interval) {
cell.setCellType(Cell.CELL_TYPE_STRING);
cell.setCellStyle(styles.get(TEXT_CELL));
cell.setCellValue(((Interval) value).getName());
} else {
cell.setCellType(Cell.CELL_TYPE_STRING);
cell.setCellStyle(styles.get(TEXT_CELL));
cell.setCellValue(value.toString());
}
}
}
// Adjust column size
for (int i = 0; i < columnCount; i++) {
sh.autoSizeColumn(i);
}
String tempXlsFile = uuidGenerator.newUuid() + ".xlsx";
Path tempXlsPath = gitStorage.createTempFile(tempXlsFile);
OutputStream os = Files.newOutputStream(tempXlsPath);
wb.write(os);
os.flush();
os.close();
// Dispose of temporary files backing this workbook on disk
if (!wb.dispose()) {
log.warn("Could not dispose of temporary file associated to data export!");
}
return Paths.convert(tempXlsPath);
} catch (Exception e) {
throw exceptionManager.handleException(e);
}
}Example 19
| Project: egovframework.rte.root-master File: EgovExcelServiceImpl.java View source code |
/* * (non-Javadoc) * @see egovframework.rte.fdl.excel.EgovExcelService#createSXSSFWorkbook(org.apache.poi.xssf.streaming.SXSSFWorkbook, java.lang.String) */ public SXSSFWorkbook createSXSSFWorkbook(SXSSFWorkbook wb, String filepath) throws BaseException, FileNotFoundException, IOException { String fullFileName = filepath; log.debug("EgovExcelServiceImpl.createWorkbook : templatePath is " + FilenameUtils.getFullPath(fullFileName)); // 작업 ë””ë ‰í† ë¦¬ ìƒ?성 if (!EgovFileUtil.isExistsFile(FilenameUtils.getFullPath(fullFileName))) { log.debug("make dir " + FilenameUtils.getFullPath(fullFileName)); try { FileUtils.forceMkdir(new File(FilenameUtils.getFullPath(fullFileName))); } catch (IOException e) { throw new IOException("Cannot create directory for path: " + FilenameUtils.getFullPath(fullFileName)); } } FileOutputStream fileOut = new FileOutputStream(fullFileName); log.debug("EgovExcelServiceImpl.createWorkbook : templatePath is " + fullFileName); try { log.debug("ExcelServiceImpl loadExcelObject ..."); wb.write(fileOut); } catch (Exception e) { log.error(getMessageSource().getMessage("error.excel.runtime.error", new Object[] { "createSXSSFWorkbook" }, Locale.getDefault()), e); } finally { log.debug("ExcelServiceImpl loadExcelObject end..."); fileOut.close(); } return wb; }
Example 20
| Project: neohort-master File: general.java View source code |
public Workbook wrapSXSSF(XSSFWorkbook xssf) {
if (getTEMPORARYFILEDURINGWRITE() != null && getTEMPORARYFILEDURINGWRITE().equalsIgnoreCase("true")) {
int rowsxss = rowSXSSFAccessWindowSize;
if (getROWSXSSFACCESSWINDOWSIZE() != null && !getROWSXSSFACCESSWINDOWSIZE().equals("")) {
try {
rowsxss = Integer.valueOf(getROWSXSSFACCESSWINDOWSIZE());
} catch (Exception e) {
}
}
if (xssf == null)
return new SXSSFWorkbook(rowsxss);
return new SXSSFWorkbook(xssf, rowsxss);
} else {
if (xssf == null)
return new XSSFWorkbook();
else
return xssf;
}
}Example 21
| Project: com.opendoorlogistics-master File: PoiIO.java View source code |
public static boolean exportDatastore(ODLDatastore<? extends ODLTableReadOnly> ds, File file, boolean xlsx, ProcessingApi processing, ExecutionReport report) {
//tmpFileBugFix();
Workbook wb = null;
SXSSFWorkbook sxssfwb = null;
HSSFWorkbook hssfwb = null;
if (xlsx == false) {
hssfwb = new HSSFWorkbook();
hssfwb.createInformationProperties();
hssfwb.getSummaryInformation().setAuthor(AppConstants.ORG_NAME);
wb = hssfwb;
} else {
// sxssfwb = new SXSSFWorkbook(100); // keep 100 rows in memory, exceeding rows will be flushed to disk
sxssfwb = new SXSSFWorkbook(null, 100, false, true);
wb = sxssfwb;
// XSSFWorkbook xssfWorkbook = new XSSFWorkbook();
/// POIXMLProperties xmlProps = sxssfwb.
//POIXMLProperties.CoreProperties coreProps = xmlProps.getCoreProperties();
// coreProps.setCreator(AppConstants.ORG_NAME);
// wb = xssfWorkbook;
}
try {
// save schema
addSchema(ds, wb);
for (ODLTableDefinition table : TableUtils.getAlphabeticallySortedTables(ds)) {
ODLTableReadOnly tro = (ODLTableReadOnly) table;
Sheet sheet = wb.createSheet(tro.getName());
if (sheet == null) {
return false;
}
exportTable(sheet, tro, 0, processing, report);
if (processing != null && processing.isCancelled()) {
return false;
}
}
if (processing != null) {
processing.postStatusMessage("Saving whole workbook to disk.");
}
saveWorkbook(file, wb);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
if (sxssfwb != null) {
sxssfwb.dispose();
}
if (hssfwb != null) {
try {
hssfwb.close();
} catch (Exception e2) {
}
}
}
return true;
}Example 22
| Project: rapidminer-studio-master File: ExcelExampleSetWriter.java View source code |
/**
* Writes the example set into a excel file with XLSX format. If you want to write it in XLS
* format use {@link #write(ExampleSet, Charset, OutputStream)}.
*
* @param exampleSet
* the exampleSet to write
* @param sheetName
* name of the excel sheet which will be created.
* @param dateFormat
* a string which describes the format used for dates.
* @param numberFormat
* a string which describes the format used for numbers.
* @param outputStream
* the stream to write the file to
* @param op
* needed for checkForStop
*/
public static void writeXLSX(ExampleSet exampleSet, String sheetName, String dateFormat, String numberFormat, OutputStream outputStream, Operator op) throws WriteException, IOException, ProcessStoppedException {
// .xlsx files can only store up to 16384 columns, so throw error in case of more
if (exampleSet.getAttributes().allSize() > 16384) {
throw new IllegalArgumentException(I18N.getMessage(I18N.getErrorBundle(), "export.excel.excel_xlsx_file_exceeds_column_limit"));
}
try (SXSSFWorkbook workbook = new SXSSFWorkbook(null, SXSSFWorkbook.DEFAULT_WINDOW_SIZE, false, true)) {
Sheet sheet = workbook.createSheet(WorkbookUtil.createSafeSheetName(sheetName));
dateFormat = dateFormat == null ? DEFAULT_DATE_FORMAT : dateFormat;
numberFormat = numberFormat == null ? "#.0" : numberFormat;
writeXLSXDataSheet(workbook, sheet, dateFormat, numberFormat, exampleSet, op);
workbook.write(outputStream);
} finally {
outputStream.flush();
outputStream.close();
}
}Example 23
| Project: sof-master File: Controller.java View source code |
public void getresultExcel(String... params) {
if (params == null) {
// c.printf("Error few parameters!\n Usage: getresult simID [destinationDirPath]");
} else {
Simulations sims = SofManager.getSimulationsData(session);
if (sims == null) {
// c.printf("No such simulation");
}
Simulation sim = null;
try {
for (Simulation s : sims.getSimulations()) if (s.getId().equals(params[0])) {
sim = s;
break;
}
} catch (IndexOutOfBoundsException e) {
}
//if no path is specified, saves in current directory
String path = (params.length < 2) ? System.getProperty("user.dir") : params[1];
path += File.separator + "SIM-" + sim.getId() + ".xls";
SXSSFWorkbook workbook = new SXSSFWorkbook();
Sheet sheet = workbook.createSheet("Simulation ID " + sim.getId());
int row_num = 0;
if (sim.getLoop()) {
List<Loop> loops = sim.getRuns().getLoops();
Collections.sort(loops, new Comparator<Loop>() {
@Override
public int compare(Loop o1, Loop o2) {
return Integer.compare(o1.getId(), o2.getId());
}
});
for (Loop l : loops) {
Row row_loop = sheet.createRow(++row_num);
Cell c_loop_id = row_loop.createCell(0);
c_loop_id.setCellValue("Loop ID " + l.getId());
class PointTree {
public Input getI() {
return i;
}
public void setI(Input i) {
this.i = i;
}
public Output getO() {
return o;
}
public void setO(Output o) {
this.o = o;
}
private Input i;
private Output o;
}
HashMap<Integer, PointTree> mapio = new HashMap<Integer, PointTree>();
if (l.getInputs() != null) {
for (Input i : l.getInputs().getinput_list()) {
PointTree p = new PointTree();
p.setI(i);
mapio.put(i.id, p);
}
if (l.getOutputs() != null && l.getOutputs().getOutput_list() != null)
for (Output i : l.getOutputs().getOutput_list()) {
mapio.get(i.getIdInput()).setO(i);
}
else {
System.out.println("No output found.");
}
for (Integer pt : mapio.keySet()) {
Row row_input_id = sheet.createRow(++row_num);
Cell c_input_id = row_input_id.createCell(1);
c_input_id.setCellValue("Input ID " + pt);
Row row_input_names = sheet.createRow(++row_num);
Row row_input_values = sheet.createRow(++row_num);
Row row_output_id = sheet.createRow(++row_num);
Cell c_output_id = row_output_id.createCell(1);
c_output_id.setCellValue("Output ID " + pt);
Row row_output_names = sheet.createRow(++row_num);
Row row_output_values = sheet.createRow(++row_num);
int cell_input = 1, cell_output = 1;
for (Parameter p : mapio.get(pt).getI().param_element) {
Cell c_input_name = row_input_names.createCell(cell_input);
Cell c_input_value = row_input_values.createCell(cell_input);
cell_input++;
c_input_name.setCellValue(p.getvariable_name());
if (p.getparam() instanceof ParameterDouble)
c_input_value.setCellValue(((ParameterDouble) p.getparam()).getvalue());
else if (p.getparam() instanceof ParameterString)
c_input_value.setCellValue(((ParameterString) p.getparam()).getvalue());
else if (p.getparam() instanceof ParameterLong)
c_input_value.setCellValue(((ParameterLong) p.getparam()).getvalue());
}
if (mapio.get(pt).getO() != null)
for (Parameter p : mapio.get(pt).getO().output_params) {
Cell c_output_name = row_output_names.createCell(cell_output);
Cell c_output_value = row_output_values.createCell(cell_output);
cell_output++;
c_output_name.setCellValue(p.getvariable_name());
if (p.getparam() instanceof ParameterDouble)
c_output_value.setCellValue(((ParameterDouble) p.getparam()).getvalue());
else if (p.getparam() instanceof ParameterString)
c_output_value.setCellValue(((ParameterString) p.getparam()).getvalue());
else if (p.getparam() instanceof ParameterLong)
c_output_value.setCellValue(((ParameterLong) p.getparam()).getvalue());
}
}
}
}
}
try {
FileOutputStream out = new FileOutputStream(new File(path));
workbook.write(out);
out.close();
System.out.println("Excel written successfully..");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}Example 24
| Project: WhiteRabbit-master File: SourceDataScan.java View source code |
private void generateReport(Map<String, List<FieldInfo>> tableToFieldInfos, String filename) {
System.out.println("Generating scan report");
removeEmptyTables(tableToFieldInfos);
List<String> tables = new ArrayList<String>(tableToFieldInfos.keySet());
Collections.sort(tables);
// keep 100 rows in memory, exceeding rows will be flushed to disk
SXSSFWorkbook workbook = new SXSSFWorkbook(100);
// Create overview sheet
Sheet sheet = workbook.createSheet("Overview");
if (!scanValues) {
addRow(sheet, "Table", "Field", "Type", "N rows");
for (String table : tables) {
for (FieldInfo fieldInfo : tableToFieldInfos.get(table)) addRow(sheet, table, fieldInfo.name, fieldInfo.getTypeDescription(), Long.valueOf(fieldInfo.rowCount));
addRow(sheet, "");
}
} else {
addRow(sheet, "Table", "Field", "Type", "Max length", "N rows", "N rows checked", "Fraction empty");
for (String table : tables) {
for (FieldInfo fieldInfo : tableToFieldInfos.get(table)) addRow(sheet, table, fieldInfo.name, fieldInfo.getTypeDescription(), Integer.valueOf(fieldInfo.maxLength), Long.valueOf(fieldInfo.rowCount), Long.valueOf(fieldInfo.nProcessed), fieldInfo.getFractionEmpty());
addRow(sheet, "");
}
// Create per table sheets
for (String table : tables) {
sheet = workbook.createSheet(table);
List<FieldInfo> fieldInfos = tableToFieldInfos.get(table);
List<List<Pair<String, Integer>>> valueCounts = new ArrayList<List<Pair<String, Integer>>>();
Object[] header = new Object[fieldInfos.size() * 2];
int maxCount = 0;
for (int i = 0; i < fieldInfos.size(); i++) {
FieldInfo fieldInfo = fieldInfos.get(i);
header[i * 2] = fieldInfo.name;
if (fieldInfo.isFreeText)
header[(i * 2) + 1] = "Word count";
else
header[(i * 2) + 1] = "Frequency";
List<Pair<String, Integer>> counts = fieldInfo.getSortedValuesWithoutSmallValues();
valueCounts.add(counts);
if (counts.size() > maxCount)
maxCount = counts.size();
}
addRow(sheet, header);
for (int i = 0; i < maxCount; i++) {
Object[] row = new Object[fieldInfos.size() * 2];
for (int j = 0; j < fieldInfos.size(); j++) {
List<Pair<String, Integer>> counts = valueCounts.get(j);
if (counts.size() > i) {
row[j * 2] = counts.get(i).getItem1();
row[(j * 2) + 1] = counts.get(i).getItem2() == -1 ? "" : counts.get(i).getItem2();
} else {
row[j * 2] = "";
row[(j * 2) + 1] = "";
}
}
addRow(sheet, row);
}
// Save some memory by derefencing tables already included in the report:
tableToFieldInfos.remove(table);
}
}
try {
FileOutputStream out = new FileOutputStream(new File(filename));
workbook.write(out);
out.close();
StringUtilities.outputWithTime("Scan report generated: " + filename);
} catch (IOException e) {
throw new RuntimeException(e.getMessage());
}
}Example 25
| Project: spreadsheet-master File: SpreadsheetFactory.java View source code |
/**
* Clears the target Spreadsheet, creates a new XLSX Workbook and loads it
* in the Spreadsheet.
*
* @param spreadsheet
* Target Spreadsheet
*/
static void loadNewXLSXSpreadsheet(Spreadsheet spreadsheet) {
Workbook workbook = spreadsheet.getWorkbook();
if (workbook != null && workbook instanceof SXSSFWorkbook) {
((SXSSFWorkbook) workbook).dispose();
}
final XSSFWorkbook newWorkbook = new XSSFWorkbook();
final Sheet sheet = createNewSheet(newWorkbook);
spreadsheet.clearSheetServerSide();
spreadsheet.setInternalWorkbook(newWorkbook);
generateNewSpreadsheet(spreadsheet, sheet, DEFAULT_ROWS, DEFAULT_COLUMNS);
setDefaultRowHeight(spreadsheet, sheet);
loadWorkbookStyles(spreadsheet);
}Example 26
| Project: akvo-flow-master File: GraphicalSurveySummaryExporter.java View source code |
@Override
public void export(Map<String, String> criteria, File fileName, String serverBase, Map<String, String> options) {
final String surveyId = criteria.get(SurveyRestRequest.SURVEY_ID_PARAM).trim();
final String apiKey = criteria.get("apiKey").trim();
processOptions(options);
questionsById = new HashMap<Long, QuestionDto>();
surveyGroupDto = BulkDataServiceClient.fetchSurveyGroup(surveyId, serverBase, apiKey);
this.serverBase = serverBase;
boolean useQuestionId = "true".equals(options.get("useQuestionId"));
String from = options.get("from");
String to = options.get("to");
String limit = options.get("maxDataReportRows");
try {
Map<QuestionGroupDto, List<QuestionDto>> questionMap = loadAllQuestions(surveyId, performGeoRollup, serverBase, apiKey);
//minimal data plus cascade level names
if (useQuestionId && DEFAULT_LOCALE.equals(locale)) {
loadQuestionOptions(surveyId, serverBase, questionMap, apiKey);
}
if (questionMap.size() > 0) {
if (!DEFAULT_LOCALE.equals(locale)) {
// we are using some other locale; need to check for translations.
// also gets option and cascade names for columns
//modifies questionMap
loadFullQuestions(questionMap, apiKey);
}
//questionMap is now stable; make the id-to-dto map
for (List<QuestionDto> qList : questionMap.values()) {
for (QuestionDto q : qList) {
questionsById.put(q.getKeyId(), q);
}
}
Workbook wb = new SXSSFWorkbook(100);
headerStyle = wb.createCellStyle();
headerStyle.setAlignment(CellStyle.ALIGN_CENTER);
Font headerFont = wb.createFont();
headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
headerStyle.setFont(headerFont);
// built-in text format
short textFormat = wb.createDataFormat().getFormat("@");
mTextStyle = wb.createCellStyle();
mTextStyle.setDataFormat(textFormat);
// This was intended to suppress scientific notation in number
// answer cells,
// but it looked bad in Excel - "3" was shown as "3."
// short numberFormat =
// wb.createDataFormat().getFormat("0.###");//Show 0-3
// decimals, never scientific
// mNumberStyle = wb.createCellStyle();
// mNumberStyle.setDataFormat(numberFormat);
SummaryModel model = fetchAndWriteRawData(criteria.get(SurveyRestRequest.SURVEY_ID_PARAM), serverBase, questionMap, wb, isFullReport, fileName, criteria.get("apiKey"), lastCollection, useQuestionId, from, to, limit);
if (isFullReport) {
writeSummaryReport(questionMap, model, null, wb);
}
if (model.getSectorList() != null && model.getSectorList().size() > 0) {
Collections.sort(model.getSectorList(), new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
if (o1 != null && o2 != null) {
return o1.toLowerCase().compareTo(o2.toLowerCase());
} else {
return 0;
}
}
});
for (String sector : model.getSectorList()) {
writeSummaryReport(questionMap, model, sector, wb);
}
}
FileOutputStream fileOut = new FileOutputStream(fileName);
wb.setActiveSheet(isFullReport ? 1 : 0);
wb.write(fileOut);
fileOut.close();
} else {
log.info("No questions for survey: " + criteria.get(SurveyRestRequest.SURVEY_ID_PARAM) + " - instance: " + serverBase);
}
} catch (Exception e) {
log.error("Error generating report: " + e.getMessage(), e);
}
}Example 27
| Project: spring-framework-master File: AbstractXlsxStreamingView.java View source code |
/**
* This implementation creates a {@link SXSSFWorkbook} for streaming the XLSX format.
*/
@Override
protected SXSSFWorkbook createWorkbook(Map<String, Object> model, HttpServletRequest request) {
return new SXSSFWorkbook();
}Example 28
| Project: bonaparte-java-master File: ExcelSXComposer.java View source code |
@Override
public void writeToFile(String filename) throws IOException {
try (FileOutputStream out = new FileOutputStream(filename)) {
write(out);
} finally {
((SXSSFWorkbook) xls).dispose();
}
}Example 29
| Project: geoserver-master File: Excel2007OutputFormat.java View source code |
/**
* Returns a new SXSSFWorkbook workbook
*/
@Override
protected Workbook getNewWorkbook() {
return new SXSSFWorkbook(1);
}Example 30
| Project: elasticsearch-dataformat-master File: XlsContent.java View source code |
@Override
public Workbook run() {
// turn off auto-flushing and accumulate all rows in memory
return new SXSSFWorkbook(-1);
}