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


Java JRBeanCollectionDataSource類代碼示例

本文整理匯總了Java中net.sf.jasperreports.engine.data.JRBeanCollectionDataSource的典型用法代碼示例。如果您正苦於以下問題:Java JRBeanCollectionDataSource類的具體用法?Java JRBeanCollectionDataSource怎麽用?Java JRBeanCollectionDataSource使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JRBeanCollectionDataSource類屬於net.sf.jasperreports.engine.data包,在下文中一共展示了JRBeanCollectionDataSource類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createDataSource

import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; //導入依賴的package包/類
private JRDataSource createDataSource() {
 	List<ReportData> datasource = new ArrayList<ReportData>();

 	ReportData data = new ReportData();
 	List<String> comments = new ArrayList<String>();
 	comments.add("comment1");
 	comments.add("comment2");
 	comments.add("comment3");
 	data.setItem("Book");
 	data.setQuantity(new Integer(10));
 	data.setComments(comments);
 	datasource.add(data);

 	data = new ReportData();
 	comments = new ArrayList<String>();
 	comments.add("comment1");
 	comments.add("comment2");
 	data.setItem("Notebook");
 	data.setQuantity(new Integer(20));
 	data.setComments(comments);
 	datasource.add(data);

	return new JRBeanCollectionDataSource(datasource);
}
 
開發者ID:svn2github,項目名稱:dynamicreports-jasper,代碼行數:25,代碼來源:ColumnListDataTypeReport.java

示例2: runReport

import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; //導入依賴的package包/類
@Override
public byte[] runReport() throws Exception {
	List<byte[]> byteList = generateReports();
	if (byteList.isEmpty()) {
		HashMap<String, String> parameterMap = new HashMap<String, String>();
		parameterMap.put("SUBREPORT_DIR", reportPath);
		parameterMap.put("directorName", ConfigurationProperties.getInstance().getPropertyValue(Property.labDirectorName));
		List<ErrorMessages> errorMsgs = new ArrayList<ErrorMessages>();
		ErrorMessages msgs = new ErrorMessages();
		msgs.setMsgLine1(StringUtil.getMessageForKey("report.error.message.noPrintableItems"));
		errorMsgs.add(msgs);
		return JasperRunManager.runReportToPdf(reportPath + "NoticeOfReportError.jasper", parameterMap, new JRBeanCollectionDataSource(
				errorMsgs));
	} else {
		return merge(byteList);
	}
}
 
開發者ID:openelisglobal,項目名稱:openelisglobal-sandbox,代碼行數:18,代碼來源:CollectionReport.java

示例3: generatePDF

import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; //導入依賴的package包/類
public PDFResponseModel generatePDF(String fileName, String template, String bucketName,
    Collection<?> items, Map<String, Object> parameters)
    throws ClassNotFoundException, JRException, IOException {

  JasperPrint jasperPrint;
  InputStream inputStream = null;

  JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(items);

  try {
    inputStream = storageUtil.getInputStream(bucketName, template);
    jasperPrint = JasperFillManager.fillReport(JasperCompileManager.compileReport(
        inputStream), parameters, beanColDataSource);
    byte[] pdfBytes = JasperExportManager.exportReportToPdf(jasperPrint);
    return new PDFResponseModel(fileName, pdfBytes);
  } catch (ClassNotFoundException | JRException | IOException e) {
    xLogger.severe("Failed to generate PDF for file name - ", fileName, e);
    throw e;
  } finally {
    if (inputStream != null) {
      inputStream.close();
    }
  }
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:25,代碼來源:JasperClient.java

示例4: generateHsfoRxPDF

import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; //導入依賴的package包/類
private ByteArrayOutputStream generateHsfoRxPDF(HttpServletRequest req){
    HsfoRxDataHolder rx = (HsfoRxDataHolder) req.getSession()
    .getAttribute(HSFO_RX_DATA_KEY);

    JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(rx.getOutlines());
    InputStream is = Thread.currentThread().getContextClassLoader()
    .getResourceAsStream("/oscar/form/prop/Hsfo_Rx.jasper");

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
        JasperRunManager.runReportToPdfStream(is, baos, rx.getParams(), ds);
    } catch (JRException e) {
        throw new RuntimeException(e);
    }
    return baos;
}
 
開發者ID:oscarservice,項目名稱:oscar-old,代碼行數:17,代碼來源:FrmPDFServlet.java

示例5: executaRelatorioPDF

import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; //導入依賴的package包/類
public void executaRelatorioPDF() throws JRException, IOException {

        InputStream reportStream = null;
        try {
            reportStream = getClass().getResourceAsStream(relatorio);
            //JasperReport report = JasperCompileManager.compileReport(reportStream);

            JRDataSource ds = new JRBeanCollectionDataSource(getDados(), true);
            //JasperPrint jasperPrint = JasperFillManager.fillReport(report, carregaParametros(), ds);
            JasperPrint jasperPrint = JasperFillManager.fillReport(reportStream, carregaParametros(), ds);

            HttpServletResponse httpServletResponse = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
            httpServletResponse.addHeader("Content-disposition", "attachment; filename=" + getArquivoSaida() + ".pdf");
            ServletOutputStream servletOutputStream = httpServletResponse.getOutputStream();
            JasperExportManager.exportReportToPdfStream(jasperPrint, servletOutputStream);
            FacesContext.getCurrentInstance().responseComplete();            

        } catch (JRException ex) {
            Logger.getLogger(ControllerBaseRelatorio.class.getName()).log(Level.SEVERE, null, ex);            
        } finally {
            if(reportStream != null)
                reportStream.close();
            
        }
    }
 
開發者ID:petroniocandido,項目名稱:GerenciadorEventos,代碼行數:26,代碼來源:ControllerBaseRelatorio.java

示例6: generate

import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; //導入依賴的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);
    }

}
 
開發者ID:ZooMMX,項目名稱:Omoikane,代碼行數:22,代碼來源:EtiquetaGenerator.java

示例7: convertReportData

import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; //導入依賴的package包/類
/**
 * Convert the given report data value to a {@code JRDataSource}.
 * <p>In the default implementation, a {@code JRDataSource},
 * {@code java.util.Collection} or object array is detected.
 * The latter are converted to {@code JRBeanCollectionDataSource}
 * or {@code JRBeanArrayDataSource}, respectively.
 * @param value the report data value to convert
 * @return the JRDataSource (never {@code null})
 * @throws IllegalArgumentException if the value could not be converted
 * @see net.sf.jasperreports.engine.JRDataSource
 * @see net.sf.jasperreports.engine.data.JRBeanCollectionDataSource
 * @see net.sf.jasperreports.engine.data.JRBeanArrayDataSource
 */
public static JRDataSource convertReportData(Object value) throws IllegalArgumentException {
	if (value instanceof JRDataSource) {
		return (JRDataSource) value;
	}
	else if (value instanceof Collection) {
		return new JRBeanCollectionDataSource((Collection<?>) value);
	}
	else if (value instanceof Object[]) {
		return new JRBeanArrayDataSource((Object[]) value);
	}
	else {
		throw new IllegalArgumentException("Value [" + value + "] cannot be converted to a JRDataSource");
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:28,代碼來源:JasperReportsUtils.java

示例8: generateHsfoRxPDF

import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; //導入依賴的package包/類
private ByteArrayOutputStream generateHsfoRxPDF(HttpServletRequest req) {

		HsfoRxDataHolder rx = (HsfoRxDataHolder) req.getSession().getAttribute(HSFO_RX_DATA_KEY);

		JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(rx.getOutlines());
		InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("/oscar/form/prop/Hsfo_Rx.jasper");

		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		try {
			JasperRunManager.runReportToPdfStream(is, baos, rx.getParams(), ds);
		} catch (JRException e) {
			throw new RuntimeException(e);
		}
		return baos;
	}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:16,代碼來源:FrmCustomedPDFServlet.java

示例9: generateReport

import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; //導入依賴的package包/類
public static <T> void generateReport(String report,
        Map<String, Object> params, Collection<T> data,
        String outputFilename) {
    try {
        InputStream reportStream = PDFReportGenerator.class
                .getResourceAsStream(report + ".jasper");
        JasperPrint jasperPrint;
        jasperPrint = JasperFillManager.fillReport(reportStream, params,
                new JRBeanCollectionDataSource(data));
        JasperExportManager.exportReportToPdfFile(jasperPrint,
                outputFilename);

        log.info("Generated Report");
    } catch (JRException e) {
        log.log(Level.WARNING, "Could not generate Report", e);
    }
}
 
開發者ID:fabianlipp,項目名稱:jnami,代碼行數:18,代碼來源:PDFReportGenerator.java

示例10: createDataSource

import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; //導入依賴的package包/類
private JRDataSource createDataSource() {
	List<Data> data = new ArrayList<Data>();

	List<SubData> subData = new ArrayList<SubData>();
	subData.add(new SubData(toDate(2011, 0, 10), 2));
	subData.add(new SubData(toDate(2011, 0, 15), 3));
	data.add(new Data("DVD", 5, new BigDecimal(30), subData));

	subData = new ArrayList<SubData>();
	subData.add(new SubData(toDate(2011, 0, 11), 1));
	subData.add(new SubData(toDate(2011, 0, 12), 3));
	subData.add(new SubData(toDate(2011, 0, 16), 4));
	data.add(new Data("Book", 8, new BigDecimal(11), subData));

	subData = new ArrayList<SubData>();
	subData.add(new SubData(toDate(2011, 0, 9), 1));
	subData.add(new SubData(toDate(2011, 0, 18), 1));
	data.add(new Data("PDA", 2, new BigDecimal(15), subData));

	return new JRBeanCollectionDataSource(data);
}
 
開發者ID:svn2github,項目名稱:dynamicreports-jasper,代碼行數:22,代碼來源:CollectionDatasourceReport.java

示例11: loadReport

import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; //導入依賴的package包/類
public void loadReport(String reportName, ReportObject reportObject) {

		logging = LoggingEngine.getInstance();
		
		try {
			
			final InputStream inputStream = ShowReport.class
					.getResourceAsStream("/com/coder/hms/reportTemplates/" + reportName + ".jrxml");
			JasperReport report = JasperCompileManager.compileReport(inputStream);

			HashMap<String, Object> parameters = new HashMap<String, Object>();	
			List<ReportObject> list = new ArrayList<ReportObject>();
			list.add(reportObject);
			JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(list);
			JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, beanColDataSource);
			final JRViewer viewer = new JRViewer(jasperPrint);

			setType(Type.POPUP);
			setResizable(false);
			setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
			this.setTitle("Reservation [Report]");
			this.setExtendedState(Frame.MAXIMIZED_BOTH);
			this.setAlwaysOnTop(isAlwaysOnTopSupported());
			this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			getContentPane().setLayout(new BorderLayout());
			this.setIconImage(Toolkit.getDefaultToolkit().
					getImage(LoginWindow.class.getResource(LOGOPATH)));
			this.setResizable(false);
			getContentPane().add(viewer, BorderLayout.CENTER);

		} catch (JRException e) {
			logging.setMessage("JRException report error!");
		}

	}
 
開發者ID:Coder-ACJHP,項目名稱:Hotel-Properties-Management-System,代碼行數:36,代碼來源:ShowReport.java

示例12: testInvoice

import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; //導入依賴的package包/類
@Test
public void testInvoice(){
  List<InvoiceItem> invoiceItems = new ArrayList<>();

  int count = 1;
  for (IDemandItem demandItem : getDemandItems()) {
    InvoiceItem invoiceItem = new InvoiceItem();
    invoiceItem.setItem(demandItem.getMaterialId().toString());
    invoiceItem.setQuantity(demandItem.getQuantity().toString());
    invoiceItem.setRecommended(demandItem.getRecommendedOrderQuantity().toString());
    invoiceItem.setRemarks("Blah");
      invoiceItem.setBatchId("AB/1234/56"+count);
      invoiceItem.setExpiry("11/03/2020");
      invoiceItem.setManufacturer("Serum");
      invoiceItem.setBatchQuantity(BigDecimal.TEN.toPlainString());
    invoiceItem.setSno(String.valueOf(count++));
    invoiceItems.add(invoiceItem);
  }

  JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(invoiceItems);

  try {

    Map<String, Object> hm = new HashMap<>();
    JasperPrint jasperPrint = JasperFillManager.fillReport(
        JasperCompileManager
            .compileReport(Thread.currentThread().getContextClassLoader().getResourceAsStream(
                "test_logistimo_invoice.jrxml")), hm, beanColDataSource);

    JasperExportManager.exportReportToPdfFile(jasperPrint, "/tmp/logistimo_invoice.pdf");


  } catch (Exception e) {
    e.printStackTrace();
  }


}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:39,代碼來源:GenerateInvoiceTest.java

示例13: generateHsfoRxPDF

import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; //導入依賴的package包/類
private ByteArrayOutputStream generateHsfoRxPDF(HttpServletRequest req){
    HsfoRxDataHolder rx = (HsfoRxDataHolder) req.getSession()
    .getAttribute(HSFO_RX_DATA_KEY);

    JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(rx.getOutlines());
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("/oscar/form/prop/Hsfo_Rx.jasper");
   
    try {
        JasperRunManager.runReportToPdfStream(is, baos, rx.getParams(), ds);
    } catch (JRException e) {
        throw new RuntimeException(e);
    }
    finally {
    	IOUtils.closeQuietly(is);
    }
    
    return baos;
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:21,代碼來源:FrmPDFServlet.java

示例14: main

import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; //導入依賴的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);
}
 
開發者ID:devang29,項目名稱:FACE-RECOGNITION-BASED-ATTENDANCE-MANAGEMENT-SYSTEM,代碼行數:25,代碼來源:Report.java

示例15: generateReport

import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; //導入依賴的package包/類
@Override
public void generateReport(KarakuReportDetails report, Align align,
		Map<String, Object> params, String type, T bean, Class<?> clazz) {

	try {
		JRDataSource datasource = new JRBeanCollectionDataSource(
				getDetails(bean));
		exportReport.exportDetailReport(report, align,
				withCriteriaVisible(), clazz, datasource, params, type);
		controllerHelper.createGlobalFacesMessage(
				FacesMessage.SEVERITY_INFO, BASE_REPORT_CREATE_SUCCESS);
	} catch (Exception e) {
		log.warn("Can't create report", e);
		controllerHelper.createGlobalFacesMessage(
				FacesMessage.SEVERITY_INFO, BASE_REPORT_CREATE_FAILURE);
	}

}
 
開發者ID:fpuna-cia,項目名稱:karaku,代碼行數:19,代碼來源:KarakuBaseReportDetail.java


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