本文整理汇总了Java中net.sf.jasperreports.engine.xml.JRXmlLoader.load方法的典型用法代码示例。如果您正苦于以下问题:Java JRXmlLoader.load方法的具体用法?Java JRXmlLoader.load怎么用?Java JRXmlLoader.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.jasperreports.engine.xml.JRXmlLoader
的用法示例。
在下文中一共展示了JRXmlLoader.load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generate
import net.sf.jasperreports.engine.xml.JRXmlLoader; //导入方法依赖的package包/类
public void generate(String reportURL,Collection<Articulo> articulos)
{
try {
InputStream is = loadReport(reportURL);
JasperDesign design = JRXmlLoader.load(is);
JasperReport report = JasperCompileManager.compileReport(design);
jp = JasperFillManager.fillReport(report,new HashMap(),new JRBeanCollectionDataSource(articulos));
JasperViewer jasperViewer = new JasperViewer(jp, false);
jasperViewer.setDefaultCloseOperation(JasperViewer.DISPOSE_ON_CLOSE);
jasperViewer.setTitle("Etiquetas");
jasperViewer.setZoomRatio((float) 1.25);
jasperViewer.setExtendedState(JasperViewer.MAXIMIZED_BOTH);
jasperViewer.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
jasperViewer.requestFocus();
jasperViewer.setVisible(true);
}catch (Exception e) {
logger.error("Error al generar etiquetas", e);
}
}
示例2: compileReport
import net.sf.jasperreports.engine.xml.JRXmlLoader; //导入方法依赖的package包/类
public JasperReport compileReport(String jrxmlFileName) throws JRException, IOException
{
JasperReport jasperReport = null;
InputStream jrxmlInput = JRLoader.getResourceInputStream(jrxmlFileName);
if (jrxmlInput != null)
{
JasperDesign design;
try
{
design = JRXmlLoader.load(jrxmlInput);
}
finally
{
jrxmlInput.close();
}
jasperReport = JasperCompileManager.compileReport(design);
}
return jasperReport;
}
示例3: compileReport
import net.sf.jasperreports.engine.xml.JRXmlLoader; //导入方法依赖的package包/类
protected void compileReport() throws JRException, IOException
{
InputStream jrxmlInput = JRLoader.getResourceInputStream(jrxml);
JasperDesign design;
try
{
design = JRXmlLoader.load(jrxmlInput);
}
finally
{
jrxmlInput.close();
}
report = JasperCompileManager.compileReport(design);
fillManager = JasperFillManager.getInstance(jasperReportsContext);
}
示例4: loadJasperDesign
import net.sf.jasperreports.engine.xml.JRXmlLoader; //导入方法依赖的package包/类
public static JasperDesign loadJasperDesign(byte[] template) throws SchemaException{
try {
byte[] reportTemplate = Base64.decodeBase64(template);
InputStream inputStreamJRXML = new ByteArrayInputStream(reportTemplate);
JasperDesign jasperDesign = JRXmlLoader.load(inputStreamJRXML);
// LOGGER.trace("load jasper design : {}", jasperDesign);
return jasperDesign;
} catch (JRException ex){
throw new SchemaException(ex.getMessage(), ex.getCause());
}
}
示例5: findReports
import net.sf.jasperreports.engine.xml.JRXmlLoader; //导入方法依赖的package包/类
private static void findReports(Map<File, String> aReportMap, File aDirectory) throws JRException {
Thread.currentThread().setContextClassLoader(JasperUtils.class.getClassLoader());
if (aDirectory != null && aDirectory.exists() && aDirectory.canRead()) {
for (File theFile : aDirectory.listFiles()) {
String theName = theFile.getName();
if (theName.endsWith(".jrxml") && (!theName.contains("_"))) {
try {
JasperDesign theDesign = JRXmlLoader.load(new FileInputStream(theFile));
String theReportName = theDesign.getName();
if (StringUtils.isNotEmpty(theReportName)) {
aReportMap.put(theFile, theReportName);
}
} catch (FileNotFoundException e) {
// This cannot happen
}
} else {
if ((theFile.isDirectory()) && (!".".equals(theName)) && (!"..".equals(theName))) {
findReports(aReportMap, theFile);
}
}
}
}
}
示例6: loadDefinitions
import net.sf.jasperreports.engine.xml.JRXmlLoader; //导入方法依赖的package包/类
/**
* Load the report definitions.
*/
@Override
public void loadDefinitions() {
jasperReports = new HashMap<String, JasperReport>();
for (Reporting report : ReportingDao.getReportingAsList()) {
File reportFile = getReportPath(report);
if (reportFile != null && reportFile.exists()) {
try {
JasperDesign jasperDesign = JRXmlLoader.load(reportFile);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
jasperReports.put(report.template, jasperReport);
if (log.isDebugEnabled()) {
log.debug("the jasper report " + report.template + " has been loaded");
}
} catch (Exception e) {
log.error("Error while loading the report " + report.template, e.getMessage());
}
} else {
log.error("Jasper report " + report.template + " not found !");
}
}
}
示例7: main
import net.sf.jasperreports.engine.xml.JRXmlLoader; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
InputStream inputStream = new FileInputStream (".\\src\\reports\\test_jasper.jrxml");
DataBeanMaker dataBeanMaker = new DataBeanMaker();
ArrayList<DataBean> dataBeanList = dataBeanMaker.getDataBeanList(null);
JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(dataBeanList);
Map parameters = new HashMap();
JasperDesign jasperDesign = JRXmlLoader.load(inputStream);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, beanColDataSource);
//JasperExportManager.exportReportToPdfFile(jasperPrint, "c:/test_jasper.pdf");
JRViewer jv=new JRViewer(jasperPrint);
JFrame jf = new JFrame();
jf.getContentPane().add(jv);
jf.validate();
jf.setVisible(true);
jf.setSize(new Dimension(1000,800));
jf.setLocation(300,100);
jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
示例8: loadJasperDesign
import net.sf.jasperreports.engine.xml.JRXmlLoader; //导入方法依赖的package包/类
/**
* Code to load a JasperDesign. We should not load a jasperDesign, since we already have one in memory.
* This code must be replaced at some point. Please note that this code use the SourceTraceDigester digester
* (not used in the JrxmlLoader. We should merge this code with the one provided by JrxmlLoader.
*/
public static JasperDesign loadJasperDesign(InputStream fileStream, SourceTraceDigester digester) throws JRException
{
try
{
JasperDesign jd = JRXmlLoader.load(fileStream);
return jd;
}
finally
{
try
{
fileStream.close();
}
catch (IOException e)
{
// ignore
}
}
}
示例9: resourceWillBeUpdated
import net.sf.jasperreports.engine.xml.JRXmlLoader; //导入方法依赖的package包/类
public void resourceWillBeUpdated(RepositoryFile repositoryFile, RepositoryReportUnit reportUnit, File file) throws Exception {
try {
JasperDesign jd = (JasperDesign) JRXmlLoader.load(file);
if (jd.getQuery() != null &&
jd.getQuery().getLanguage() != null &&
jd.getQuery().getLanguage().equalsIgnoreCase("xmla-mdx"))
{
JOptionPane.showMessageDialog(Misc.getMainFrame(), "You are trying to upload on JasperServer a report which uses the xmla-mdx query language.\nThis language is not supported by JasperServer and it is outdated.\nYou should use the mdx language instead.", "Unsupported language", JOptionPane.WARNING_MESSAGE);
}
} catch (Exception ex)
{
ex.printStackTrace();
}
}
示例10: load
import net.sf.jasperreports.engine.xml.JRXmlLoader; //导入方法依赖的package包/类
@Override
public JasperTemplate load(String name) {
URL url = templateURLs.get(name);
if (url != null) {
JasperDesign jasperDesign;
try {
jasperDesign = JRXmlLoader.load(url.openStream());
} catch (Exception e) {
throw SeedException.wrap(e, JasperErrorCode.ERROR_LOADING_JASPER_REPORT)
.put("template", name)
.put("url", url.toExternalForm());
}
return new JasperTemplate(jasperDesign, url.getFile());
} else {
return null;
}
}
示例11: createJasperPrint
import net.sf.jasperreports.engine.xml.JRXmlLoader; //导入方法依赖的package包/类
/**
* generate report ByteArrayOutputStream
*
* @param jrDataSource data for report
* @param template report template
* @return report ByteArrayOutputStream
* @throws JRException will occurred generating report
*/
public JasperPrint createJasperPrint(JRDataSource jrDataSource, String template)throws JRException {
// create a byte array from given report template
byte[] templateBytes = template.getBytes();
InputStream templateInputStream = new ByteArrayInputStream(templateBytes);
JasperPrint jasperPrint;
try {
// load JasperDesign
JasperDesign jasperDesign = JRXmlLoader.load(templateInputStream);
// compiling JasperDesign from JasperCompileManager
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
// generate JasperPrint Object from given JasperReport file and JRDataSource by JasperFillManager
jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap(), jrDataSource);
} catch (JRException e) {
throw new JRException("JasperPrint creation failed from " + template , e);
}
return jasperPrint;
}
示例12: renderDocument
import net.sf.jasperreports.engine.xml.JRXmlLoader; //导入方法依赖的package包/类
@Override
public void renderDocument() {
try {
switch (getExtension(reportTemplate)) {
case JASPER_EXT:
printReport((JasperReport) JRLoader.loadObject(reportTemplate.getDocumentContent()));
break;
case JRXML_EXT:
JasperDesign design = JRXmlLoader.load(reportTemplate.getDocumentContent());
if (!design.getParametersMap().containsKey(CUBA_PARAM))
design.addParameter(createJRParameter());
printReport(JasperCompileManager.compileReport(design));
break;
default:
throw new ReportFormattingException("Error handling template extension");
}
} catch (JRException e) {
throw new ReportFormattingException("Error formatting jasper report: " + e.getMessage(), e);
}
}
示例13: imprimirClientesActivos
import net.sf.jasperreports.engine.xml.JRXmlLoader; //导入方法依赖的package包/类
@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT)
@MemberOrder(sequence = "3")
public Blob imprimirClientesActivos() throws JRException, IOException {
ClientesActivosDataSource datasource = new ClientesActivosDataSource();
for (Cliente cli : clientesRepository.listarActivos()){
ClientesActivosReporte reporteClientesActivos=new ClientesActivosReporte();
reporteClientesActivos.setClienteNombre(cli.getClienteNombre());
reporteClientesActivos.setClienteApellido(cli.getClienteApellido());
reporteClientesActivos.setClienteDni(cli.getClienteDni());
reporteClientesActivos.setClienteTipoDocumento(cli.getClienteTipoDocumento().toString());
reporteClientesActivos.setPersonaMail(cli.getPersonaMail());
reporteClientesActivos.setPersonaTelefono(cli.getPersonaTelefono());
datasource.addParticipante(reporteClientesActivos);
}
String jrxml = "ClientesActivos.jrxml";
String nombreArchivo = "Listado Clientes Activos ";
InputStream input = ReporteRepository.class.getResourceAsStream(jrxml);
JasperDesign jd = JRXmlLoader.load(input);
JasperReport reporte = JasperCompileManager.compileReport(jd);
Map<String, Object> parametros = new HashMap<String, Object>();
JasperPrint jasperPrint = JasperFillManager.fillReport(reporte, parametros, datasource);
return ReporteRepository.imprimirReporteLista(jasperPrint, jrxml, nombreArchivo);
}
示例14: imprimirFacturacionAnualPorCompania
import net.sf.jasperreports.engine.xml.JRXmlLoader; //导入方法依赖的package包/类
@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT)
@MemberOrder(sequence = "5")
public Blob imprimirFacturacionAnualPorCompania() throws JRException, IOException {
FacturacionDataSource datasource = new FacturacionDataSource();
for (FacturacionCompaniasViewModel fac : facturacionRepository.facturacion()){
FacturacionReporte facturacionCompania =new FacturacionReporte();
facturacionCompania.setCompania(fac.getCompania().getCompaniaNombre().toString());
facturacionCompania.setPrimaTotal(fac.getPrimaTotal());
datasource.addParticipante(facturacionCompania);
}
String jrxml = "FacturacionCompanias.jrxml";
String nombreArchivo = "Facturacion companias ";
InputStream input = ReporteRepository.class.getResourceAsStream(jrxml);
JasperDesign jd = JRXmlLoader.load(input);
JasperReport reporte = JasperCompileManager.compileReport(jd);
Map<String, Object> parametros = new HashMap<String, Object>();
JasperPrint jasperPrint = JasperFillManager.fillReport(reporte, parametros, datasource);
return ReporteRepository.imprimirReporteLista(jasperPrint, jrxml, nombreArchivo);
}
示例15: imprimirPolizasPorCompania
import net.sf.jasperreports.engine.xml.JRXmlLoader; //导入方法依赖的package包/类
@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT)
@MemberOrder(sequence = "6")
public Blob imprimirPolizasPorCompania(
@ParameterLayout(named="Compania: ") final Compania companiaSeleccionada) throws JRException, IOException {
PolizaPorCompaniaDataSource datasource = new PolizaPorCompaniaDataSource();
for (Poliza pol : polizaRepository.buscarPorCompania(companiaSeleccionada)){
PolizaPorCompaniaReporte reportePolizaPorCompania =new PolizaPorCompaniaReporte();
reportePolizaPorCompania.setPolizasCliente(pol.getPolizaCliente().toString());
reportePolizaPorCompania.setPolizasCompania(pol.getPolizaCompania().getCompaniaNombre());
reportePolizaPorCompania.setPolizaNumero(pol.getPolizaNumero());
reportePolizaPorCompania.setPolizaFechaVigencia(pol.getPolizaFechaVigencia());
reportePolizaPorCompania.setPolizaFechaVencimiento(pol.getPolizaFechaVencimiento());
reportePolizaPorCompania.setPolizaFechaEmision(pol.getPolizaFechaEmision());
reportePolizaPorCompania.setPolizaImporteTotal(pol.getPolizaImporteTotal());
datasource.addParticipante(reportePolizaPorCompania);
}
String jrxml = "PolizasPorCompania.jrxml";
String nombreArchivo = "Listado de polizas por compania"+" "+companiaSeleccionada.getCompaniaNombre()+" ";
InputStream input = ReporteRepository.class.getResourceAsStream(jrxml);
JasperDesign jd = JRXmlLoader.load(input);
JasperReport reporte = JasperCompileManager.compileReport(jd);
Map<String, Object> parametros = new HashMap<String, Object>();
parametros.put("compania", companiaSeleccionada.getCompaniaNombre());
JasperPrint jasperPrint = JasperFillManager.fillReport(reporte, parametros, datasource);
return ReporteRepository.imprimirReporteLista(jasperPrint, jrxml, nombreArchivo);
}