本文整理汇总了Java中net.sf.jasperreports.engine.util.JRLoader.loadObjectFromFile方法的典型用法代码示例。如果您正苦于以下问题:Java JRLoader.loadObjectFromFile方法的具体用法?Java JRLoader.loadObjectFromFile怎么用?Java JRLoader.loadObjectFromFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.jasperreports.engine.util.JRLoader
的用法示例。
在下文中一共展示了JRLoader.loadObjectFromFile方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: print
import net.sf.jasperreports.engine.util.JRLoader; //导入方法依赖的package包/类
/**
*
*/
public boolean print(
String sourceFileName,
int firstPageIndex,
int lastPageIndex,
boolean withPrintDialog
) throws JRException
{
JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObjectFromFile(sourceFileName);
return
print(
jasperPrint,
firstPageIndex,
lastPageIndex,
withPrintDialog
);
}
示例2: gerarDanfe
import net.sf.jasperreports.engine.util.JRLoader; //导入方法依赖的package包/类
private static void gerarDanfe(String url, List<String> emit, List<String> dest, List<String> nota, JRDataSource itens, String qrcode){
try {
// Teste
//String compilado = System.getProperty("user.dir") + "/danfe_nfce_80.jasper";;
String output = "danfe.pdf";
map.put("emit", emit);
map.put("dest", dest);
map.put("nota", nota);
map.put("qrcode", qrcode);
// Relatório compilado
JasperReport report = (JasperReport) JRLoader.loadObjectFromFile(url);
//InputStream jasperStream = getClass().getResourceAsStream("/Foo.jasper");
//JasperReport report = (JasperReport) JRLoader.loadObject(jasperStream);
// Relatório nao compilado
//JasperReport report = JasperCompileManager.compileReport(jrxml);
JasperPrint print = JasperFillManager.fillReport(report, map, itens);
JasperExportManager.exportReportToPdfFile(print, output);
} catch (JRException e) {
System.out.println("erro: "+e.getMessage());
}
}
示例3: gerarDanfeNFe
import net.sf.jasperreports.engine.util.JRLoader; //导入方法依赖的package包/类
private static void gerarDanfeNFe(String url, List<String> emit, List<String> dest, List<String> nota, JRDataSource itens) {
try {
// Teste
//String compilado = System.getProperty("user.dir") + "/danfe_nfce_80.jasper";;
String output = "danfe.pdf";
map.put("emit", emit);
map.put("dest", dest);
map.put("nota", nota);
// Relatório compilado
JasperReport report = (JasperReport) JRLoader.loadObjectFromFile(url);
JasperPrint print = JasperFillManager.fillReport(report, map, itens);
JasperExportManager.exportReportToPdfFile(print, output);
} catch (JRException e) {
System.out.println("erro: "+e.getMessage());
}
}
示例4: gerarDanfeNfse
import net.sf.jasperreports.engine.util.JRLoader; //导入方法依赖的package包/类
private static void gerarDanfeNfse(String url, List<String> emit, List<String> dest, List<String> ser, List<String> nota, String xml, String logo) {
try {
// Teste
//String compilado = System.getProperty("user.dir") + "/danfe_nfce_80.jasper";;
String output = "danfe.pdf";
map.put("emit", emit);
map.put("dest", dest);
map.put("ser", ser);
map.put("nota", nota);
map.put("logo", logo);
// brasao
String brasao = Paths.get(System.getProperty("user.dir"), "danfe","brasao.png").toAbsolutePath().toString();
map.put("brasao", brasao);
// JrDataSource
JRDataSource jr = new JRXmlDataSource(xml);
// Relatório compilado
JasperReport report = (JasperReport) JRLoader.loadObjectFromFile(url);
JasperPrint print = JasperFillManager.fillReport(report, map, jr);
JasperExportManager.exportReportToPdfFile(print, output);
} catch (JRException e) {
System.out.println("erro: "+e.getMessage());
}
}
示例5: fill
import net.sf.jasperreports.engine.util.JRLoader; //导入方法依赖的package包/类
/**
*
*/
public void fill() throws JRException
{
long start = System.currentTimeMillis();
JasperReport subreport = (JasperReport)JRLoader.loadObjectFromFile("build/reports/ProductReport.jasper");
//Preparing parameters
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("ProductsSubreport", subreport);
JasperFillManager.fillReportToFile("build/reports/MasterReport.jasper", parameters, getDemoHsqldbConnection());
System.err.println("Filling time : " + (System.currentTimeMillis() - start));
}
示例6: jsonMetadata
import net.sf.jasperreports.engine.util.JRLoader; //导入方法依赖的package包/类
/**
*
*/
public void jsonMetadata() throws JRException
{
long start = System.currentTimeMillis();
JasperReport subreport = (JasperReport)JRLoader.loadObjectFromFile("build/reports/ProductReport.jasper");
//Preparing parameters
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("ProductsSubreport", subreport);
parameters.put(JRParameter.IS_IGNORE_PAGINATION, true);
JasperPrint jasperPrint = JasperFillManager.fillReport("build/reports/MasterReport.jasper", parameters, getDemoHsqldbConnection());
System.err.println("Filling time : " + (System.currentTimeMillis() - start));
start = System.currentTimeMillis();
File destFile = new File(new File("build/reports"), jasperPrint.getName() + ".json");
JsonMetadataExporter exporter = new JsonMetadataExporter();
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
exporter.setExporterOutput(new SimpleWriterExporterOutput(destFile));
exporter.exportReport();
System.err.println("JSON creation time : " + (System.currentTimeMillis() - start));
}
示例7: exportToPdfFile
import net.sf.jasperreports.engine.util.JRLoader; //导入方法依赖的package包/类
/**
* Exports the generated report file specified by the first parameter into PDF format,
* the result being placed in the second file parameter.
*
* @param sourceFileName source file containing the generated report
* @param destFileName file name to place the PDF content into
* @see net.sf.jasperreports.engine.export.JRPdfExporter
*/
public void exportToPdfFile(
String sourceFileName,
String destFileName
) throws JRException
{
JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObjectFromFile(sourceFileName);
exportReportToPdfFile(jasperPrint, destFileName);
}
示例8: exportToXmlFile
import net.sf.jasperreports.engine.util.JRLoader; //导入方法依赖的package包/类
/**
* Exports the generated report file specified by the first parameter into XML format,
* placing the result into the second file parameter.
* <p>
* If not embedded into the XML content itself using the Base64 encoder,
* the images are placed as distinct files inside a directory having the same name
* as the XML destination file, plus the "_files" suffix.
*
* @param sourceFileName source file containing the generated report
* @param destFileName file name to place the XML representation into
* @param isEmbeddingImages flag that indicates whether the images should be embedded in the
* XML content itself using the Base64 encoder or be referenced as external resources
* @see net.sf.jasperreports.engine.export.JRPdfExporter
*/
public void exportToXmlFile(
String sourceFileName,
String destFileName,
boolean isEmbeddingImages
) throws JRException
{
JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObjectFromFile(sourceFileName);
exportReportToXmlFile(
jasperPrint,
destFileName,
isEmbeddingImages
);
}
示例9: exportToHtmlFile
import net.sf.jasperreports.engine.util.JRLoader; //导入方法依赖的package包/类
/**
* Exports the generated report file specified by the first parameter into HTML format,
* placing the result into the second file parameter.
* <p>
* The images are placed as distinct files inside a directory having the same name
* as the HTML destination file, plus the "_files" suffix.
*
* @param sourceFileName source file containing the generated report
* @param destFileName file name to place the HTML content into
* @see net.sf.jasperreports.engine.export.JRPdfExporter
*/
public void exportToHtmlFile(
String sourceFileName,
String destFileName
) throws JRException
{
JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObjectFromFile(sourceFileName);
exportReportToHtmlFile(
jasperPrint,
destFileName
);
}
示例10: printToImage
import net.sf.jasperreports.engine.util.JRLoader; //导入方法依赖的package包/类
/**
*
*/
public Image printToImage(
String sourceFileName,
int pageIndex,
float zoom
) throws JRException
{
JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObjectFromFile(sourceFileName);
return printToImage(jasperPrint, pageIndex, zoom);
}
示例11: writeToXmlFile
import net.sf.jasperreports.engine.util.JRLoader; //导入方法依赖的package包/类
/**
* Generates the XML representation of the report design loaded from the first file parameter
* and place it in the file specified by the second parameter. The result is "UTF-8" encoded.
*
* @param sourceFileName source file name containing the report design object
* @param destFileName output file name to write the XML report design representation to
*/
public void writeToXmlFile(
String sourceFileName,
String destFileName
) throws JRException
{
JRReport report = (JRReport)JRLoader.loadObjectFromFile(sourceFileName);
writeToXmlFile(report, destFileName);
}
示例12: service
import net.sf.jasperreports.engine.util.JRLoader; //导入方法依赖的package包/类
@Override
public void service(
HttpServletRequest request,
HttpServletResponse response
) throws IOException, ServletException
{
ServletContext context = this.getServletConfig().getServletContext();
response.setContentType("text/html");
PrintWriter out = response.getWriter();
try
{
File reportFile = new File(context.getRealPath("/reports/WebappReport.jasper"));
if (!reportFile.exists())
throw new JRRuntimeException("File WebappReport.jasper not found. The report design must be compiled first.");
JasperReport jasperReport = (JasperReport)JRLoader.loadObjectFromFile(reportFile.getPath());
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("ReportTitle", "Address Report");
parameters.put("BaseDir", reportFile.getParentFile());
JasperPrint jasperPrint =
JasperFillManager.fillReport(
jasperReport,
parameters,
new WebappDataSource()
);
HtmlExporter exporter = new HtmlExporter();
request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint);
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
SimpleHtmlExporterOutput output = new SimpleHtmlExporterOutput(out);
output.setImageHandler(new WebHtmlResourceHandler("image?image={0}"));
exporter.setExporterOutput(output);
exporter.exportReport();
}
catch (JRException e)
{
out.println("<html>");
out.println("<head>");
out.println("<title>JasperReports - Web Application Sample</title>");
out.println("<link rel=\"stylesheet\" type=\"text/css\" href=\"../stylesheet.css\" title=\"Style\">");
out.println("</head>");
out.println("<body bgcolor=\"white\">");
out.println("<span class=\"bnew\">JasperReports encountered this error :</span>");
out.println("<pre>");
e.printStackTrace(out);
out.println("</pre>");
out.println("</body>");
out.println("</html>");
}
}
示例13: export
import net.sf.jasperreports.engine.util.JRLoader; //导入方法依赖的package包/类
/**
* Performs the export of the selected report files.
*/
protected void export() throws BuildException
{
Collection<String> files = reportFilesMap.keySet();
if (files != null && files.size() > 0)
{
boolean isError = false;
System.out.println("Exporting " + files.size() + " report files.");
String srcFileName = null;
String destFileName = null;
File destFileParent = null;
for (Iterator<String> it = files.iterator(); it.hasNext();)
{
srcFileName = it.next();
destFileName = reportFilesMap.get(srcFileName);
destFileParent = new File(destFileName).getParentFile();
if(!destFileParent.exists())
{
destFileParent.mkdirs();
}
try
{
System.out.print("File : " + srcFileName + " ... ");
JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObjectFromFile(srcFileName);
JasperExportManager.getInstance(jasperReportsContext).exportToXmlFile(jasperPrint, destFileName, false);
System.out.println("OK.");
}
catch(JRException e)
{
System.out.println("FAILED.");
System.out.println("Error updating report design : " + srcFileName);
e.printStackTrace(System.out);
isError = true;
}
}
if(isError)
{
throw new BuildException("Errors were encountered when updating report designs.");
}
}
}
示例14: decompile
import net.sf.jasperreports.engine.util.JRLoader; //导入方法依赖的package包/类
/**
* Performs the decompilation of the selected report design files.
*/
protected void decompile() throws BuildException
{
Collection<String> files = reportFilesMap.keySet();
if (files != null && files.size() > 0)
{
boolean isError = false;
System.out.println("Decompiling " + files.size() + " report design files.");
for (Iterator<String> it = files.iterator(); it.hasNext();)
{
String srcFileName = it.next();
String destFileName = reportFilesMap.get(srcFileName);
File destFileParent = new File(destFileName).getParentFile();
if(!destFileParent.exists())
{
destFileParent.mkdirs();
}
try
{
System.out.print("File : " + srcFileName + " ... ");
JasperReport jasperReport = (JasperReport)JRLoader.loadObjectFromFile(srcFileName);
new JRXmlWriter(jasperReportsContext).write(jasperReport, destFileName, "UTF-8");
System.out.println("OK.");
}
catch(JRException e)
{
System.out.println("FAILED.");
System.out.println("Error decompiling report design : " + srcFileName);
e.printStackTrace(System.out);
isError = true;
}
}
if(isError)
{
throw new BuildException("Errors were encountered when decompiling report designs.");
}
}
}