use of io.jmix.ui.download.DownloadFormat in project jmix by jmix-framework.
the class PivotExcelExporter method export.
protected void export(Downloader downloader) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
wb.write(out);
} catch (IOException e) {
throw new RuntimeException("Unable to write document", e);
}
if (fileName == null) {
fileName = DEFAULT_FILE_NAME;
}
DownloadFormat downloadFormat = exportFormat == ExportFormat.XLS ? DownloadFormat.XLS : DownloadFormat.XLSX;
downloader.download(new ByteArrayDataProvider(out.toByteArray(), uiProperties.getSaveExportedByteArrayDataThresholdBytes(), coreProperties.getTempDir()), fileName + "." + downloadFormat.getFileExt(), downloadFormat);
}
use of io.jmix.ui.download.DownloadFormat in project jmix by jmix-framework.
the class UiReportRunnerImpl method showResult.
protected void showResult(ReportOutputDocument document, UiReportRunContext context) {
String templateCode = getTemplateCode(context);
Map<String, Object> params = context.getParams();
ReportOutputType outputType = context.getOutputType();
if (document.getReportOutputType().getId().equals(JmixReportOutputType.chart.getId())) {
ShowChartScreen showChartScreen = (ShowChartScreen) screens.create("report_ShowChart.screen", OpenMode.DIALOG);
showChartScreen.setChartJson(new String(document.getContent(), StandardCharsets.UTF_8));
showChartScreen.setReport((Report) document.getReport());
showChartScreen.setTemplateCode(templateCode);
showChartScreen.setReportParameters(params);
showChartScreen.show();
} else if (document.getReportOutputType().getId().equals(JmixReportOutputType.pivot.getId())) {
ShowPivotTableScreen showPivotTableScreen = (ShowPivotTableScreen) screens.create("report_ShowPivotTable.screen", OpenMode.DIALOG);
showPivotTableScreen.setPivotTableData(document.getContent());
showPivotTableScreen.setReport((Report) document.getReport());
showPivotTableScreen.setTemplateCode(templateCode);
showPivotTableScreen.setParams(params);
showPivotTableScreen.show();
} else if (document.getReportOutputType().getId().equals(JmixReportOutputType.table.getId())) {
ShowReportTableScreen reportTable = (ShowReportTableScreen) screens.create("report_ShowReportTable.screen", OpenMode.DIALOG);
reportTable.setTableData(document.getContent());
reportTable.setReport((Report) document.getReport());
reportTable.setTemplateCode(templateCode);
reportTable.setReportParameters(params);
reportTable.show();
} else {
byte[] byteArr = document.getContent();
com.haulmont.yarg.structure.ReportOutputType finalOutputType = (outputType != null) ? outputType.getOutputType() : document.getReportOutputType();
DownloadFormat exportFormat = DownloadFormat.getByExtension(finalOutputType.getId());
String outputFileName = context.getOutputNamePattern();
String documentName = isNotBlank(outputFileName) ? outputFileName : document.getDocumentName();
downloader.download(byteArr, documentName, exportFormat);
}
}
use of io.jmix.ui.download.DownloadFormat in project jmix by jmix-framework.
the class WebExportDisplay method show.
@Override
public void show(ExportDataProvider dataProvider, String resourceName, @Nullable ExportFormat format) {
DownloadFormat downloadFormat = format == null ? null : format.getDownloadFormat();
delegate.download(dataProvider, resourceName, downloadFormat);
}
use of io.jmix.ui.download.DownloadFormat in project jmix by jmix-framework.
the class WebExportDisplay method show.
@Override
public void show(FileDescriptor fileDescriptor, @Nullable ExportFormat format) {
DownloadFormat downloadFormat = format == null ? null : format.getDownloadFormat();
delegate.download(cubaFileStorage.toFileRef(fileDescriptor), downloadFormat);
}
Aggregations