当前位置: 首页>>代码示例>>Java>>正文


Java JasperDesign.setQuery方法代码示例

本文整理汇总了Java中net.sf.jasperreports.engine.design.JasperDesign.setQuery方法的典型用法代码示例。如果您正苦于以下问题:Java JasperDesign.setQuery方法的具体用法?Java JasperDesign.setQuery怎么用?Java JasperDesign.setQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.jasperreports.engine.design.JasperDesign的用法示例。


在下文中一共展示了JasperDesign.setQuery方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: gerarRelatorioEstoquePdf

import net.sf.jasperreports.engine.design.JasperDesign; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public void gerarRelatorioEstoquePdf(String sql, int totalProdutos){
	try{
		String caminhoSalvar = "";
       	DirectoryChooser directoryChooser = new DirectoryChooser();
           File selectedDirectory = directoryChooser.showDialog(null);
            
           if(selectedDirectory == null){
               System.out.println("N�o selecionou nada");
           }else{
               caminhoSalvar = selectedDirectory.getAbsolutePath();
           }
           if(!caminhoSalvar.isEmpty()){
           	Connection conn = new ConexaoBD().getConnection();
   			HashMap param = new HashMap();
   			param.put("totalProdutos", totalProdutos);
   			JasperDesign jd = JRXmlLoader.load("src/main/java/br/com/buyme/report/VerificaEstoque.jrxml");
   			JRDesignQuery newQuery = new JRDesignQuery();
   			newQuery.setText(sql);
   			jd.setQuery(newQuery);
   			JasperReport jr = JasperCompileManager.compileReport(jd);
   			JasperPrint jp = JasperFillManager.fillReport(jr, param,conn);
   			JasperExportManager.exportReportToPdfFile(jp,caminhoSalvar+"/Estoque.pdf");
   			conn.close();
           }
	}catch(Exception e){
		e.printStackTrace();
	}
}
 
开发者ID:juan0101,项目名称:TG-BUYME,代码行数:30,代码来源:ProdutoProntoDAO.java

示例2: gerarRelatorioPdf

import net.sf.jasperreports.engine.design.JasperDesign; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public void gerarRelatorioPdf(String sql){
	try{
		String caminhoSalvar = "";
       	DirectoryChooser directoryChooser = new DirectoryChooser();
           File selectedDirectory = directoryChooser.showDialog(null);
            
           if(selectedDirectory == null){
               System.out.println("N�o selecionou nada");
           }else{
               caminhoSalvar = selectedDirectory.getAbsolutePath();
           }
           if(!caminhoSalvar.isEmpty()){
           	Connection conn = new ConexaoBD().getConnection();
   			HashMap param = new HashMap();
		
			JasperDesign jd = JRXmlLoader.load("src/main/java/br/com/buyme/report/MotivoPerda.jrxml");
   			JRDesignQuery newQuery = new JRDesignQuery();
   			newQuery.setText(sql);
   			jd.setQuery(newQuery);
   			JasperReport jr = JasperCompileManager.compileReport(jd);
   			JasperPrint jp = JasperFillManager.fillReport(jr, param,conn);
   			JasperExportManager.exportReportToPdfFile(jp,caminhoSalvar+"/MotivoPerda.pdf");
		
   			conn.close();
           }
	}catch(Exception e){
		e.printStackTrace();
	}
	
}
 
开发者ID:juan0101,项目名称:TG-BUYME,代码行数:32,代码来源:RelatorioMotivoPerdaLoteDAO.java

示例3: getTemplate

import net.sf.jasperreports.engine.design.JasperDesign; //导入方法依赖的package包/类
public byte[] getTemplate(){
		try{
//			design.remadgetFields().
			design.getFieldsList().clear();
			design.getParametersList().clear();
            design.getFieldsMap().clear();
            design.getParametersMap().clear();
            for (JasperReportFieldDto field : fields) {
				if (field.isEmpty()){
					continue;
				}
				JRDesignField f = new JRDesignField();
				f.setValueClassName(field.getTypeAsString());
				f.setValueClass(Class.forName(field.getTypeAsString()));
				f.setName(field.getName());
				design.addField(f);
			}

			for (JasperReportParameterDto param : parameters) {
				if (param.isEmpty()) {
					continue;
				}
				JRDesignParameter p = new JRDesignParameter();
				p.setValueClassName(param.getTypeAsString());
				p.setValueClass(Class.forName(param.getTypeAsString()));
				p.setName(param.getName());
				p.setForPrompting(param.isForPrompting());
				p.setDescription(param.getDescription());
				p.setNestedTypeName(param.getNestedTypeAsString());
				p.setNestedType(param.getNestedType());
				p.getPropertiesMap().setBaseProperties(param.getJRProperties());
				//			p.getPropertiesMap().setProperty(propName, value);
				design.addParameter(p);
			}

			JasperDesign oldDesign = ReportTypeUtil.loadJasperDesign(jasperReportXml);
			oldDesign.getParametersList().clear();
			oldDesign.getParametersList().addAll(design.getParametersList());

			oldDesign.getFieldsList().clear();
			oldDesign.getFieldsList().addAll(design.getFieldsList());

			JRDesignQuery q = new JRDesignQuery();
			q.setLanguage("mql");
			q.setText(query);
			oldDesign.setQuery(q);

			String reportAsString = JRXmlWriter.writeReport(oldDesign, "UTF-8");
			return Base64.encodeBase64(reportAsString.getBytes("UTF-8"));

		} catch (JRException | ClassNotFoundException | SchemaException | UnsupportedEncodingException ex) {
			throw new IllegalStateException(ex.getMessage(), ex.getCause());
		}
		
	}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:56,代码来源:JasperReportDto.java


注:本文中的net.sf.jasperreports.engine.design.JasperDesign.setQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。