當前位置: 首頁>>代碼示例>>Java>>正文


Java JRLoader.loadObjectFromFile方法代碼示例

本文整理匯總了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
			);
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:21,代碼來源:JasperPrintManager.java

示例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());
    }
}
 
開發者ID:juniortada,項目名稱:Java-Danfe,代碼行數:22,代碼來源:DanfeNfe.java

示例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());
    }
}
 
開發者ID:juniortada,項目名稱:Java-Danfe,代碼行數:17,代碼來源:DanfeNfe.java

示例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());
    }
}
 
開發者ID:juniortada,項目名稱:Java-Danfe,代碼行數:24,代碼來源:DanfeNfe.java

示例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));
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:16,代碼來源:SubreportApp.java

示例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));
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:30,代碼來源:SubreportApp.java

示例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);
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:18,代碼來源:JasperExportManager.java

示例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
		);
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:29,代碼來源:JasperExportManager.java

示例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
		);
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:24,代碼來源:JasperExportManager.java

示例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);
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:14,代碼來源:JasperPrintManager.java

示例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);
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:17,代碼來源:JasperCompileManager.java

示例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>");
	}
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:63,代碼來源:HtmlServlet.java

示例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.");
		}
	}
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:53,代碼來源:JRAntXmlExportTask.java

示例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.");
		}
	}
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:49,代碼來源:JRAntDecompileTask.java


注:本文中的net.sf.jasperreports.engine.util.JRLoader.loadObjectFromFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。