use of com.serotonin.m2m2.vo.event.EventInstanceEmporter in project ma-core-public by infiniteautomation.
the class EventExportServlet method exportExcel.
/**
* @param response
* @param def
* @param user
* @throws IOException
*/
private void exportExcel(HttpServletResponse response, User user) throws IOException {
// Stream the content.
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
final EventInstanceEmporter sheetEmporter = new EventInstanceEmporter();
final SpreadsheetEmporter emporter = new SpreadsheetEmporter(FileType.XLSX);
BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream());
emporter.prepareExport(bos);
emporter.prepareSheetExport(sheetEmporter);
QueryDefinition queryData = (QueryDefinition) user.getAttribute("eventInstanceExportDefinition");
DojoQueryCallback<EventInstanceVO> callback = new DojoQueryCallback<EventInstanceVO>(false) {
@Override
public void row(EventInstanceVO vo, int rowIndex) {
sheetEmporter.exportRow(vo);
}
};
EventInstanceDao.instance.exportQuery(queryData.getQuery(), queryData.getSort(), null, null, queryData.isOr(), callback);
emporter.finishExport();
}
Aggregations