|
@@ -31,29 +31,20 @@ import com.uas.report.util.DataSourceUtils;
|
|
|
import com.uas.report.util.FileUtils;
|
|
import com.uas.report.util.FileUtils;
|
|
|
import com.uas.report.util.ReportConstants;
|
|
import com.uas.report.util.ReportConstants;
|
|
|
|
|
|
|
|
-import net.sf.jasperreports.engine.JRBand;
|
|
|
|
|
-import net.sf.jasperreports.engine.JRElement;
|
|
|
|
|
import net.sf.jasperreports.engine.JRException;
|
|
import net.sf.jasperreports.engine.JRException;
|
|
|
-import net.sf.jasperreports.engine.JRExporterParameter;
|
|
|
|
|
-import net.sf.jasperreports.engine.JRSection;
|
|
|
|
|
-import net.sf.jasperreports.engine.JRTextField;
|
|
|
|
|
import net.sf.jasperreports.engine.JasperCompileManager;
|
|
import net.sf.jasperreports.engine.JasperCompileManager;
|
|
|
-import net.sf.jasperreports.engine.JasperExportManager;
|
|
|
|
|
import net.sf.jasperreports.engine.JasperFillManager;
|
|
import net.sf.jasperreports.engine.JasperFillManager;
|
|
|
import net.sf.jasperreports.engine.JasperPrint;
|
|
import net.sf.jasperreports.engine.JasperPrint;
|
|
|
import net.sf.jasperreports.engine.JasperReport;
|
|
import net.sf.jasperreports.engine.JasperReport;
|
|
|
import net.sf.jasperreports.engine.design.JasperDesign;
|
|
import net.sf.jasperreports.engine.design.JasperDesign;
|
|
|
import net.sf.jasperreports.engine.export.JRPdfExporter;
|
|
import net.sf.jasperreports.engine.export.JRPdfExporter;
|
|
|
import net.sf.jasperreports.engine.export.JRXlsExporter;
|
|
import net.sf.jasperreports.engine.export.JRXlsExporter;
|
|
|
-import net.sf.jasperreports.engine.export.JRXlsExporterParameter;
|
|
|
|
|
import net.sf.jasperreports.engine.xml.JRXmlLoader;
|
|
import net.sf.jasperreports.engine.xml.JRXmlLoader;
|
|
|
import net.sf.jasperreports.export.ExporterInput;
|
|
import net.sf.jasperreports.export.ExporterInput;
|
|
|
import net.sf.jasperreports.export.OutputStreamExporterOutput;
|
|
import net.sf.jasperreports.export.OutputStreamExporterOutput;
|
|
|
import net.sf.jasperreports.export.SimpleExporterInput;
|
|
import net.sf.jasperreports.export.SimpleExporterInput;
|
|
|
import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput;
|
|
import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput;
|
|
|
import net.sf.jasperreports.export.SimplePdfReportConfiguration;
|
|
import net.sf.jasperreports.export.SimplePdfReportConfiguration;
|
|
|
-import net.sf.jasperreports.export.SimpleXlsExporterConfiguration;
|
|
|
|
|
-import net.sf.jasperreports.export.XlsExporterConfiguration;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 报表打印
|
|
* 报表打印
|
|
@@ -290,39 +281,6 @@ public class PrintServiceImpl implements PrintService {
|
|
|
return jasperFilePath;
|
|
return jasperFilePath;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 以不同的格式导出报表
|
|
|
|
|
- *
|
|
|
|
|
- * @param jasperPrint
|
|
|
|
|
- * @param exportFileType
|
|
|
|
|
- * @param outputStream
|
|
|
|
|
- */
|
|
|
|
|
- // private void exportReport(JasperPrint jasperPrint, String exportFileType,
|
|
|
|
|
- // OutputStream outputStream) {
|
|
|
|
|
- // try {
|
|
|
|
|
- // if (exportFileType.equals("pdf")) {
|
|
|
|
|
- // exportReportToPdf(jasperPrint, outputStream);
|
|
|
|
|
- // } else if (exportFileType.equals("xls")) {
|
|
|
|
|
- // exportReportToXls(jasperPrint, outputStream);
|
|
|
|
|
- // } else {
|
|
|
|
|
- // throw new ReportException("不支持导出为 " + exportFileType + "格式!");
|
|
|
|
|
- // }
|
|
|
|
|
- // } catch (JRException e) {
|
|
|
|
|
- // throw new ReportException(e).setDetailedMessage(e);
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 以pdf的格式导出报表
|
|
|
|
|
- *
|
|
|
|
|
- * @param jasperPrint
|
|
|
|
|
- * @param outputStream
|
|
|
|
|
- * @throws JRException
|
|
|
|
|
- */
|
|
|
|
|
- private void exportReportToPdf(JasperPrint jasperPrint, OutputStream outputStream) throws JRException {
|
|
|
|
|
- JasperExportManager.exportReportToPdfStream(jasperPrint, outputStream);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 以xls的格式导出报表
|
|
* 以xls的格式导出报表
|
|
|
*
|
|
*
|
|
@@ -333,12 +291,6 @@ public class PrintServiceImpl implements PrintService {
|
|
|
private void exportReportToXls(JasperPrint jasperPrint, OutputStream outputStream, boolean customCellStyle)
|
|
private void exportReportToXls(JasperPrint jasperPrint, OutputStream outputStream, boolean customCellStyle)
|
|
|
throws JRException {
|
|
throws JRException {
|
|
|
JRXlsExporter exporter = new CustomJRXlsExporter(customCellStyle);
|
|
JRXlsExporter exporter = new CustomJRXlsExporter(customCellStyle);
|
|
|
- // SimpleXlsExporterConfiguration configuration = new
|
|
|
|
|
- // SimpleXlsExporterConfiguration();
|
|
|
|
|
- // configuration.setCreateCustomPalette(true);
|
|
|
|
|
- // configuration.setKeepWorkbookTemplateSheets(true);
|
|
|
|
|
- // configuration.setOverrideHints(true);
|
|
|
|
|
- // exporter.setConfiguration(configuration);
|
|
|
|
|
ExporterInput exporterInput = new SimpleExporterInput(jasperPrint);
|
|
ExporterInput exporterInput = new SimpleExporterInput(jasperPrint);
|
|
|
exporter.setExporterInput(exporterInput);
|
|
exporter.setExporterInput(exporterInput);
|
|
|
OutputStreamExporterOutput exporterOutput = new SimpleOutputStreamExporterOutput(outputStream);
|
|
OutputStreamExporterOutput exporterOutput = new SimpleOutputStreamExporterOutput(outputStream);
|
|
@@ -373,15 +325,6 @@ public class PrintServiceImpl implements PrintService {
|
|
|
jasperDesign.setLeftMargin(0);
|
|
jasperDesign.setLeftMargin(0);
|
|
|
jasperDesign.setBottomMargin(0);
|
|
jasperDesign.setBottomMargin(0);
|
|
|
jasperDesign.setRightMargin(0);
|
|
jasperDesign.setRightMargin(0);
|
|
|
-
|
|
|
|
|
- // 设置DetailBand中的元素高度不动态调整
|
|
|
|
|
- // JRSection detailSection = jasperDesign.getDetailSection();
|
|
|
|
|
- // JRBand[] bands = detailSection.getBands();
|
|
|
|
|
- // JRElement[] elements = bands[0].getElements();
|
|
|
|
|
- // for (JRElement element : elements) {
|
|
|
|
|
- // JRTextField textField = (JRTextField) element;
|
|
|
|
|
- // textField.setStretchWithOverflow(false);
|
|
|
|
|
- // }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|