use of org.apache.poi.xssf.streaming.SXSSFWorkbook in project tdi-studio-se by Talend.
the class ExcelTool method prepareStream.
public void prepareStream() throws Exception {
wb = new SXSSFWorkbook(rowAccessWindowSize);
sheet = wb.createSheet(sheetName);
if (isAbsY) {
startX = absX;
curY = absY;
}
}
use of org.apache.poi.xssf.streaming.SXSSFWorkbook in project tdi-studio-se by Talend.
the class ExcelTool method prepareXlsxFile.
public void prepareXlsxFile(String fileName) throws Exception {
File xlsxFile = new File(fileName);
if (xlsxFile.exists()) {
if (isAbsY && keepCellFormat) {
initPreXlsx(fileName);
}
if (appendWorkbook) {
InputStream inp = new FileInputStream(fileName);
wb = WorkbookFactory.create(inp);
sheet = wb.getSheet(sheetName);
if (sheet != null) {
if (appendSheet) {
if (sheet.getLastRowNum() != 0 || sheet.getRow(0) != null) {
curY = sheet.getLastRowNum() + 1;
}
} else {
wb.removeSheetAt(wb.getSheetIndex(sheetName));
sheet = wb.createSheet(sheetName);
}
} else {
sheet = wb.createSheet(sheetName);
}
} else {
xlsxFile.delete();
wb = new SXSSFWorkbook(rowAccessWindowSize);
sheet = wb.createSheet(sheetName);
}
} else {
wb = new SXSSFWorkbook(rowAccessWindowSize);
sheet = wb.createSheet(sheetName);
}
if (isAbsY) {
startX = absX;
curY = absY;
}
}
use of org.apache.poi.xssf.streaming.SXSSFWorkbook in project poi by apache.
the class Outlining method collapseRow.
private void collapseRow() throws IOException {
SXSSFWorkbook wb2 = new SXSSFWorkbook(100);
SXSSFSheet sheet2 = wb2.createSheet("new sheet");
int rowCount = 20;
for (int i = 0; i < rowCount; i++) {
sheet2.createRow(i);
}
sheet2.groupRow(4, 9);
sheet2.groupRow(11, 19);
sheet2.setRowGroupCollapsed(4, true);
FileOutputStream fileOut = new FileOutputStream("outlining_collapsed.xlsx");
try {
wb2.write(fileOut);
} finally {
fileOut.close();
wb2.dispose();
wb2.close();
}
}
use of org.apache.poi.xssf.streaming.SXSSFWorkbook in project poi by apache.
the class TestSXSSFBugs method bug49253.
/**
* Setting repeating rows and columns shouldn't break
* any print settings that were there before
*/
@Test
public void bug49253() throws Exception {
Workbook wb1 = new SXSSFWorkbook();
Workbook wb2 = new SXSSFWorkbook();
CellRangeAddress cra = CellRangeAddress.valueOf("C2:D3");
// No print settings before repeating
Sheet s1 = wb1.createSheet();
s1.setRepeatingColumns(cra);
s1.setRepeatingRows(cra);
PrintSetup ps1 = s1.getPrintSetup();
assertEquals(false, ps1.getValidSettings());
assertEquals(false, ps1.getLandscape());
// Had valid print settings before repeating
Sheet s2 = wb2.createSheet();
PrintSetup ps2 = s2.getPrintSetup();
ps2.setLandscape(false);
assertEquals(true, ps2.getValidSettings());
assertEquals(false, ps2.getLandscape());
s2.setRepeatingColumns(cra);
s2.setRepeatingRows(cra);
ps2 = s2.getPrintSetup();
assertEquals(true, ps2.getValidSettings());
assertEquals(false, ps2.getLandscape());
wb1.close();
wb2.close();
}
use of org.apache.poi.xssf.streaming.SXSSFWorkbook in project poi by apache.
the class TestUnfixedBugs method testBug54084Unicode.
@Test
public void testBug54084Unicode() throws IOException {
// sample XLSX with the same text-contents as the text-file above
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("54084 - Greek - beyond BMP.xlsx");
verifyBug54084Unicode(wb);
// OutputStream baos = new FileOutputStream("/tmp/test.xlsx");
// try {
// wb.write(baos);
// } finally {
// baos.close();
// }
// now write the file and read it back in
XSSFWorkbook wbWritten = XSSFTestDataSamples.writeOutAndReadBack(wb);
verifyBug54084Unicode(wbWritten);
// finally also write it out via the streaming interface and verify that we still can read it back in
SXSSFWorkbook swb = new SXSSFWorkbook(wb);
Workbook wbStreamingWritten = SXSSFITestDataProvider.instance.writeOutAndReadBack(swb);
verifyBug54084Unicode(wbStreamingWritten);
wbWritten.close();
swb.close();
wbStreamingWritten.close();
wb.close();
}
Aggregations