Exportar plantilla HTML personalizada
Antecedentes
Exportar a HTML genera lo siguiente:
<html>
<head>
<title></title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<style type="text/css">
a {text-decoration: none}
</style>
</head>
<body vlink="#000000" text="#000000" link="#000000" alink="#000000">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="50%"> </td>
<td align="center">
<!-- The report -->
</td>
<td width="50%"> </td>
</tr>
</tbody>
</table>
</body>
</html>
ProblemaEl informe se centra en la página, pero debe alinearse a la izquierda.
Solución anteriorEl uso del parámetro HTML_HEADER de JRHtmlExporter parecía prometedor, pero las clases han sidoobsoleto. Esta fue la solución:
JRHtmlExporter exporter = new JRHtmlExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER,
"<html>"+
"<head>"+
" <title></title>"+
" <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>"+
" <link rel=\"stylesheet\" type=\"text/css\" href=\"css/jasper.css\" />"+
" <style type="text/css">"+
" a {text-decoration: none}"+
" </style>"+
"</head>"+
"<body text="#000000" link="#000000" alink="#000000" vlink="#000000">"+
"<table width="100%" cellpadding="0" cellspacing="0" border="0">"+
"<tr><td width="50%"> </td><td align="center">");
exporter.exportReport();
Ahora tengo que usar elnet.sf.jasperreports.export.HtmlExporter
ynet.sf.jasperreports.export.SimpleHtmlReportConfiguration
clases, de esta manera:
HtmlExporter exporterHTML = new HtmlExporter();
SimpleExporterInput exporterInput = new SimpleExporterInput(report.getJasperPrint());
exporterHTML.setExporterInput(exporterInput);
HtmlExporterOutput exporterOutput = new SimpleHtmlExporterOutput(out);
exporterHTML.setExporterOutput(exporterOutput );
SimpleHtmlReportConfiguration reportExportConfiguration = new SimpleHtmlReportConfiguration();
reportExportConfiguration.setWhitePageBackground(false);
reportExportConfiguration.setRemoveEmptySpaceBetweenRows(true);
exporterHTML.setConfiguration(reportExportConfiguration);
exporterHTML.exportReport();
¿Cómo arreglarías esto?
AmbienteJasperReports v5.5.2Java v1.6.0_38