Search in sources :

Example 1 with XlsTableWriter

use of org.activityinfo.io.xls.XlsTableWriter in project activityinfo by bedatadriven.

the class ExportFormExecutor method execute.

@Override
public ExportResult execute(ExportFormJob descriptor) throws IOException {
    TableModel tableModel = descriptor.getTableModel();
    GeneratedResource export = storageProvider.create(XlsTableWriter.EXCEL_MIME_TYPE, "Export.xls");
    TableViewModel viewModel = new TableViewModel(formSource, tableModel);
    EffectiveTableModel effectiveTableModel = viewModel.getEffectiveTable().waitFor();
    ColumnSet columnSet = effectiveTableModel.getColumnSet().waitFor();
    XlsTableWriter writer = new XlsTableWriter();
    writer.addSheet(effectiveTableModel, columnSet);
    try (OutputStream out = export.openOutputStream()) {
        writer.write(out);
    }
    return new ExportResult(export.getDownloadUri());
}
Also used : EffectiveTableModel(org.activityinfo.analysis.table.EffectiveTableModel) XlsTableWriter(org.activityinfo.io.xls.XlsTableWriter) TableViewModel(org.activityinfo.analysis.table.TableViewModel) OutputStream(java.io.OutputStream) ColumnSet(org.activityinfo.model.query.ColumnSet) GeneratedResource(org.activityinfo.server.generated.GeneratedResource) EffectiveTableModel(org.activityinfo.analysis.table.EffectiveTableModel) TableModel(org.activityinfo.model.analysis.TableModel) ExportResult(org.activityinfo.model.job.ExportResult)

Aggregations

OutputStream (java.io.OutputStream)1 EffectiveTableModel (org.activityinfo.analysis.table.EffectiveTableModel)1 TableViewModel (org.activityinfo.analysis.table.TableViewModel)1 XlsTableWriter (org.activityinfo.io.xls.XlsTableWriter)1 TableModel (org.activityinfo.model.analysis.TableModel)1 ExportResult (org.activityinfo.model.job.ExportResult)1 ColumnSet (org.activityinfo.model.query.ColumnSet)1 GeneratedResource (org.activityinfo.server.generated.GeneratedResource)1