use of org.molgenis.data.excel.ExcelSheetWriter in project molgenis by molgenis.
the class DataExplorerDownloadHandler method writeToExcel.
public void writeToExcel(DataRequest dataRequest, OutputStream outputStream) throws IOException {
String entityTypeId = dataRequest.getEntityName();
List<Attribute> attributes = filterAttributes(dataRequest);
checkNumberOfCells(dataRequest, entityTypeId, attributes.size());
AttributeWriteMode attributeWriteMode = getAttributeWriteMode(dataRequest.getColNames());
try (ExcelWriter excelWriter = new ExcelWriter(outputStream, attrMetaFactory, FileFormat.XLSX);
ExcelSheetWriter excelSheetWriter = excelWriter.createWritable(entityTypeId, attributes, attributeWriteMode)) {
excelSheetWriter.setEntityWriteMode(getEntityWriteMode(dataRequest.getEntityValues()));
excelSheetWriter.add(dataService.findAll(entityTypeId, dataRequest.getQuery()));
}
}
Aggregations