Search in sources :

Example 1 with ExcelWriter

use of org.molgenis.data.excel.ExcelWriter 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()));
    }
}
Also used : Attribute(org.molgenis.data.meta.model.Attribute) ExcelWriter(org.molgenis.data.excel.ExcelWriter) AttributeWriteMode(org.molgenis.data.support.AbstractWritable.AttributeWriteMode) ExcelSheetWriter(org.molgenis.data.excel.ExcelSheetWriter)

Aggregations

ExcelSheetWriter (org.molgenis.data.excel.ExcelSheetWriter)1 ExcelWriter (org.molgenis.data.excel.ExcelWriter)1 Attribute (org.molgenis.data.meta.model.Attribute)1 AttributeWriteMode (org.molgenis.data.support.AbstractWritable.AttributeWriteMode)1