我有一个在 excel 中输出的 jasper 报告,我想在 excel 中禁用“网格线”选项以使背景全白。
我如何在 jasper 报告中做到这一点?
编辑:以下示例对我有用!!
你直接在你的 jrxml 中设置这个属性
net.sf.jasperreports.export.xls.show.gridlines=false
,默认值为true
jrxml 示例
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="reputation" printOrder="Horizontal" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isSummaryNewPage="true" uuid="a88bd694-4f90-41fc-84d0-002b90b2d73e">
<property name="net.sf.jasperreports.export.xls.show.gridlines" value="false"/>
....
</jasperReport>
或者如果您要从 java 导出,请设置 SimpleXlsReportConfiguration.setShowGridLines(false)
Java 示例
JRXlsExporter exporterXls = new JRXlsExporter();
exporterXls.setExporterInput(new SimpleExporterInput(jasperPrint));
exporterXls.setExporterOutput(new SimpleOutputStreamExporterOutput(new File("excelTest.xls")));
SimpleXlsReportConfiguration configXls = new SimpleXlsReportConfiguration();
configXls.setShowGridLines(false);
//set your additional settings
exporterXls.setConfiguration(configXls);
exporterXls.exportReport();
Note: The code shows xls (since tagged xls) example but the same property can be used for the
SimpleXlsxReportConfiguration
(xlsx)
最佳答案
你直接在你的 jrxml 中设置这个属性
net.sf.jasperreports.export.xls.show.gridlines=false
,默认值为true
jrxml 示例
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="reputation" printOrder="Horizontal" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isSummaryNewPage="true" uuid="a88bd694-4f90-41fc-84d0-002b90b2d73e">
<property name="net.sf.jasperreports.export.xls.show.gridlines" value="false"/>
....
</jasperReport>
或者如果您要从 java 导出,请设置 SimpleXlsReportConfiguration.setShowGridLines(false)
Java 示例
JRXlsExporter exporterXls = new JRXlsExporter();
exporterXls.setExporterInput(new SimpleExporterInput(jasperPrint));
exporterXls.setExporterOutput(new SimpleOutputStreamExporterOutput(new File("excelTest.xls")));
SimpleXlsReportConfiguration configXls = new SimpleXlsReportConfiguration();
configXls.setShowGridLines(false);
//set your additional settings
exporterXls.setConfiguration(configXls);
exporterXls.exportReport();
Note: The code shows xls (since tagged xls) example but the same property can be used for the
SimpleXlsxReportConfiguration
(xlsx)
关于java - 如何禁用 Excel 报告中的 "grid line"选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44032451/