本文整理汇总了Java中net.sf.jasperreports.engine.export.JRTextExporter.exportReport方法的典型用法代码示例。如果您正苦于以下问题:Java JRTextExporter.exportReport方法的具体用法?Java JRTextExporter.exportReport怎么用?Java JRTextExporter.exportReport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.jasperreports.engine.export.JRTextExporter
的用法示例。
在下文中一共展示了JRTextExporter.exportReport方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveTxtReportToFile
import net.sf.jasperreports.engine.export.JRTextExporter; //导入方法依赖的package包/类
/**
* Generates a plain text report from a pre-compiled report and returns it into a file.
*
* @param jasperPrint
* JasperPrint object which contains a compiled report.
* @param file
* The file used to return the report.
* @throws JRException
* In case there is any error generating the report an exception is thrown with the
* error message.
*/
private static void saveTxtReportToFile(JasperPrint jasperPrint, File file) throws JRException {
final JRTextExporter textExporter = new JRTextExporter();
SimpleExporterInput exporterInput = new SimpleExporterInput(jasperPrint);
SimpleWriterExporterOutput exporterOutput = new SimpleWriterExporterOutput(file);
// Default text configuration that can be overridden in the .jrxml template itself
SimpleTextExporterConfiguration textExporterConfiguration = new SimpleTextExporterConfiguration();
textExporterConfiguration.setOverrideHints(false);
textExporter.setConfiguration(textExporterConfiguration);
// Default item text configuration that can be overridden in the .jrxml template itself
SimpleTextReportConfiguration textReportConfiguration = new SimpleTextReportConfiguration();
textReportConfiguration.setCharHeight(new Float(TEXT_CHAR_HEIGHT));
textReportConfiguration.setCharWidth(new Float(TEXT_CHAR_WIDTH));
textReportConfiguration.setOverrideHints(false);
textExporter.setConfiguration(textReportConfiguration);
textExporter.setExporterInput(exporterInput);
textExporter.setExporterOutput(exporterOutput);
textExporter.exportReport();
}
示例2: saveTxtReportToOutputStream
import net.sf.jasperreports.engine.export.JRTextExporter; //导入方法依赖的package包/类
/**
* Generates a plain text report from a pre-compiled report and returns it into an output stream.
*
* @param jasperPrint
* JasperPrint object which contains a compiled report.
* @param outputStream
* The output stream used to return the report.
* @throws JRException
* In case there is any error generating the report an exception is thrown with the
* error message.
*/
private static void saveTxtReportToOutputStream(JasperPrint jasperPrint, OutputStream outputStream)
throws JRException {
final JRTextExporter textExporter = new JRTextExporter();
SimpleExporterInput exporterInput = new SimpleExporterInput(jasperPrint);
SimpleWriterExporterOutput exporterOutput = new SimpleWriterExporterOutput(outputStream);
// Default text configuration that can be overridden in the .jrxml template itself
SimpleTextExporterConfiguration textExporterConfiguration = new SimpleTextExporterConfiguration();
textExporterConfiguration.setOverrideHints(false);
textExporter.setConfiguration(textExporterConfiguration);
// Default item text configuration that can be overridden in the .jrxml template itself
SimpleTextReportConfiguration textReportConfiguration = new SimpleTextReportConfiguration();
textReportConfiguration.setCharHeight(new Float(TEXT_CHAR_HEIGHT));
textReportConfiguration.setCharWidth(new Float(TEXT_CHAR_WIDTH));
textReportConfiguration.setOverrideHints(false);
textExporter.setConfiguration(textReportConfiguration);
textExporter.setExporterInput(exporterInput);
textExporter.setExporterOutput(exporterOutput);
textExporter.exportReport();
}
示例3: text
import net.sf.jasperreports.engine.export.JRTextExporter; //导入方法依赖的package包/类
/**
*
*/
public void text() throws JRException
{
long start = System.currentTimeMillis();
JRTextExporter exporter = new JRTextExporter();
File sourceFile = new File("build/reports/TextReport.jrprint");
JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);
File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".txt");
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
exporter.setExporterOutput(new SimpleWriterExporterOutput(destFile));
exporter.exportReport();
System.err.println("Text creation time : " + (System.currentTimeMillis() - start));
}
示例4: exportToTxt
import net.sf.jasperreports.engine.export.JRTextExporter; //导入方法依赖的package包/类
private void exportToTxt() {
//log.debug("exporting to TXT");
// textExporter = new JRTextExporter();
// setExportParameter(JRTextExporterParameter.CHARACTER_WIDTH, new
// Integer(13));
// setExportParameter(JRTextExporterParameter.CHARACTER_HEIGHT, new
// Integer(20));
textExporter = new JRTextExporter();
if (getJasperReport().hasProperties()) {
if (null != getJasperReport().getProperty("export.txt.page_rows")) {
setExportParameter(JRTextExporterParameter.CHARACTER_WIDTH,
getJasperReport().getProperty("export.txt.character_width"));
}
if (null != getJasperReport().getProperty("export.txt.page_columns")) {
setExportParameter(JRTxtExporterParameter.PAGE_COLUMNS,
getJasperReport().getProperty("export.txt.page_columns"));
}
if (null != getJasperReport().getProperty(
"export.txt.add_form_feed")) {
setExportParameter(JRTxtExporterParameter.ADD_FORM_FEED,
new Boolean(getJasperReport().getProperty(
"export.txt.add_form_feed")));
}
}
textExporter.setParameters(getExportParameters());
try {
start = System.currentTimeMillis();
textExporter.exportReport();
//log.info("export running time (msec): "
// + (System.currentTimeMillis() - start));
} catch (JRException jre) {
jre.printStackTrace();
}
}
示例5: toTxtFile
import net.sf.jasperreports.engine.export.JRTextExporter; //导入方法依赖的package包/类
public static void toTxtFile(JasperPrint jasperPrint, Map exporterParams, String txtFile) throws JRException {
System.out.println("JasperUtil.toTxtFile");
Timer timer = new Timer();
timer.start();
JRTextExporter exporter = new JRTextExporter();
exporter.setParameters(exporterParams);
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, txtFile);
exporter.exportReport();
timer.end();
System.out.println("To txt in " + timer.duration());
}
示例6: saveTxtReport
import net.sf.jasperreports.engine.export.JRTextExporter; //导入方法依赖的package包/类
/**
* Generates a plain text report using the SimpleExporterInput, SimpleWriterExporterOutput,
* SimpleTextExporterConfiguration and SimpleTextReportConfiguration received as parameters.
*
* @param exporterInput
* SimpleExporterInput object with the input data.
* @param exporterOutput
* SimpleWriterExporterOutput object with the output data.
* @param textExporterConfiguration
* SimpleTextExporterConfiguration with the configuration data.
* @param textReportConfiguration
* SimpleTextReportConfiguration with the item configuration data.
* @throws JRException
* In case there is any error generating the report an exception is thrown with the
* error message.
*/
public static void saveTxtReport(SimpleExporterInput exporterInput,
SimpleWriterExporterOutput exporterOutput,
SimpleTextExporterConfiguration textExporterConfiguration,
SimpleTextReportConfiguration textReportConfiguration) throws JRException {
final JRTextExporter textExporter = new JRTextExporter();
textExporter.setExporterInput(exporterInput);
textExporter.setExporterOutput(exporterOutput);
textExporter.setConfiguration(textExporterConfiguration);
textExporter.setConfiguration(textReportConfiguration);
textExporter.exportReport();
}