I would like to use the xagent principle to create exports from Notes view using Apache Poi.
But instead of 1 exported file with multiple sheets I would like to create multiple exports, each containing just 1 sheet.
Is possible? e.g.
importPackage(java.lang);
importPackage(org.apache.poi.hssf.usermodel);
var fieldList = sessionScope.fList;
var sheetName = "viewData";
var workbookName = "WBViewData";
var vName = sessionScope.viewName;
var nc: NotesView = database.getView(vName);
var doc: NotesDocument;
var ndoc: NotesDocument;
doc = nc.getFirstDocument();
for (d = 1; d <= nc.getEntryCount(); d++) {
//Create a new workbook object from the poi library
var wb: HSSFWorkbook = new HSSFWorkbook();
//Create additional sheets using same syntax and different sheet name
var sheet1: HSSFSheet = wb.createSheet(sheetName);
//Create helper class and styles for dates
var createHelper: HSSFCreationHelper = wb.getCreationHelper();
var dateStyle: HSSFCellStyle = wb.createCellStyle();
dateStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy"));
var headerStyle: HSSFCellStyle = wb.createCellStyle();
var headerFont: HSSFFont = wb.createFont();
headerFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
headerStyle.setFont(headerFont);
//Create the Column Header Rows
var row: HSSFRow = sheet1.createRow(0);
for (i = 0; i <= fieldList.length - 1; i++) {
var hCell: HSSFCell = row.createCell((java.lang.Integer)(i));
hCell.setCellValue(fieldList[i]);
hCell.setCellStyle(headerStyle);
}
var row: HSSFRow = sheet1.createRow(d);
// process document...
//Create the filename for the spreadsheet
var fileName = workbookName + ".xls";
// The Faces Context global object provides access to the servlet environment via the external content
var extCont = facesContext.getExternalContext();
// The servlet's response object provides control to the response object
var pageResponse = extCont.getResponse();
//Get the output stream to stream binary data
var pageOutput = pageResponse.getOutputStream();
// Set the content type and headers
pageResponse.setContentType("application/x-ms-excel");
pageResponse.setHeader("Cache-Control", "no-cache");
pageResponse.setHeader("Content-Disposition", "inline; filename=" + fileName);
//Write the output, flush the buffer and close the stream
wb.write(pageOutput);
pageOutput.flush();
pageOutput.close();
ndoc = nc.getNextDocument(doc);
doc.recycle();
doc = ndoc;
}
// Terminate the request processing lifecycle.
facesContext.responseComplete();