use of org.apache.poi.xssf.streaming.SXSSFRow in project poi by apache.
the class SavePasswordProtectedXlsx method main.
public static void main(String[] args) throws Exception {
if (args.length != 2) {
throw new IllegalArgumentException("Expected 2 params: filename and password");
}
TempFileUtils.checkTempFiles();
String filename = args[0];
String password = args[1];
SXSSFWorkbookWithCustomZipEntrySource wb = new SXSSFWorkbookWithCustomZipEntrySource();
try {
for (int i = 0; i < 10; i++) {
SXSSFSheet sheet = wb.createSheet("Sheet" + i);
for (int r = 0; r < 1000; r++) {
SXSSFRow row = sheet.createRow(r);
for (int c = 0; c < 100; c++) {
SXSSFCell cell = row.createCell(c);
cell.setCellValue("abcd");
}
}
}
EncryptedTempData tempData = new EncryptedTempData();
try {
wb.write(tempData.getOutputStream());
save(tempData.getInputStream(), filename, password);
System.out.println("Saved " + filename);
} finally {
tempData.dispose();
}
} finally {
wb.close();
wb.dispose();
}
TempFileUtils.checkTempFiles();
}
Aggregations