本文整理汇总了Java中net.sf.jasperreports.engine.data.JRXmlDataSource类的典型用法代码示例。如果您正苦于以下问题:Java JRXmlDataSource类的具体用法?Java JRXmlDataSource怎么用?Java JRXmlDataSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JRXmlDataSource类属于net.sf.jasperreports.engine.data包,在下文中一共展示了JRXmlDataSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: gerarDanfeNfse
import net.sf.jasperreports.engine.data.JRXmlDataSource; //导入依赖的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());
}
}
示例2: execute
import net.sf.jasperreports.engine.data.JRXmlDataSource; //导入依赖的package包/类
public static JasperPrint execute(int[] hits, String query) {
itemMap = new HashMap<String, Item>();
for (int i = 0; i < hits.length; i++) {
process(BisisApp.getRecordManager().getRecord(hits[i]));
}
StringBuffer buff = new StringBuffer();
buff.append("<report>\n");
List keys = new ArrayList();
keys.addAll(itemMap.keySet());
Collections.sort(keys);
Iterator branchIDs = keys.iterator();
while (branchIDs.hasNext()) {
String key = (String) branchIDs.next();
Item item = (Item) itemMap.get(key);
buff.append(item.toString());
}
buff.append("</report>\n");
try {
JRXmlDataSource dataSource = new JRXmlDataSource(XMLUtils
.getDocumentFromString(buff.toString()), "/report/item");
Map param = new HashMap();
param.put("query", query);
JasperPrint jp = JasperFillManager
.fillReport(
NabavkaPoNacinu.class
.getResource(
"/com/gint/app/bisis4/client/hitlist/groupview/NabavkaPoNacinu.jasper")
.openStream(), param, dataSource);
return jp;
} catch (Exception ex) {
return null;
}
}
示例3: execute
import net.sf.jasperreports.engine.data.JRXmlDataSource; //导入依赖的package包/类
public static JasperPrint execute(int[] hits, String query) {
itemMap = new HashMap<String, Item>();
for (int i = 0; i < hits.length; i++) {
process(BisisApp.getRecordManager().getRecord(hits[i]));
}
StringBuffer buff = new StringBuffer();
buff.append("<report>\n");
List keys = new ArrayList();
keys.addAll(itemMap.keySet());
Collections.sort(keys);
Iterator branchIDs = keys.iterator();
while (branchIDs.hasNext()) {
String key = (String) branchIDs.next();
Item item = (Item) itemMap.get(key);
buff.append(item.toString());
}
buff.append("</report>\n");
try {
JRXmlDataSource dataSource = new JRXmlDataSource(XMLUtils.getDocumentFromString(buff.toString()), "/report/item");
Map param = new HashMap();
param.put("query", query);
JasperPrint jp = JasperFillManager
.fillReport(
PogodciPoPeriodu.class
.getResource(
"/com/gint/app/bisis4/client/hitlist/groupview/PogodciPoPeriodu.jasper")
.openStream(), param, dataSource);
return jp;
} catch (Exception ex) {
return null;
}
}
示例4: execute
import net.sf.jasperreports.engine.data.JRXmlDataSource; //导入依赖的package包/类
public static JasperPrint execute(int[] hits, String query) {
itemMap = new HashMap<String, Item>();
for (int i = 0; i < hits.length; i++) {
process(BisisApp.getRecordManager().getRecord(hits[i]));
}
StringBuffer buff = new StringBuffer();
buff.append("<report>\n");
List keys = new ArrayList();
keys.addAll(itemMap.keySet());
Collections.sort(keys);
Iterator branchIDs = keys.iterator();
while (branchIDs.hasNext()) {
String key = (String) branchIDs.next();
Item item = (Item) itemMap.get(key);
buff.append(item.toString());
}
buff.append("</report>\n");
try {
JRXmlDataSource dataSource = new JRXmlDataSource(XMLUtils
.getDocumentFromString(buff.toString()), "/report/item");
Map param = new HashMap();
param.put("query", query);
JasperPrint jp = JasperFillManager
.fillReport(
PogodciPoPovezu.class
.getResource(
"/com/gint/app/bisis4/client/hitlist/groupview/PogodciPoPovezu.jasper")
.openStream(), param, dataSource);
return jp;
} catch (Exception ex) {
return null;
}
}
示例5: execute
import net.sf.jasperreports.engine.data.JRXmlDataSource; //导入依赖的package包/类
public static JasperPrint execute(int[] hits, String query) {
itemMap = new HashMap<String, Item>();
for (int i = 0; i < hits.length; i++) {
process(BisisApp.getRecordManager().getRecord(hits[i]));
}
StringBuffer buff = new StringBuffer();
buff.append("<report>\n");
List keys = new ArrayList();
keys.addAll(itemMap.keySet());
Collections.sort(keys);
Iterator branchIDs = keys.iterator();
while (branchIDs.hasNext()) {
String key = (String) branchIDs.next();
Item item = (Item) itemMap.get(key);
buff.append(item.toString());
}
buff.append("</report>\n");
try {
JRXmlDataSource dataSource = new JRXmlDataSource(XMLUtils
.getDocumentFromString(buff.toString()), "/report/item");
Map param = new HashMap();
param.put("query", query);
JasperPrint jp = JasperFillManager
.fillReport(
NabavkaPoNacinu.class
.getResource(
"/com/gint/app/bisis4/client/hitlist/groupview/JeziciPoOgrancima.jasper")
.openStream(), param, dataSource);
return jp;
} catch (Exception ex) {
return null;
}
}
示例6: execute
import net.sf.jasperreports.engine.data.JRXmlDataSource; //导入依赖的package包/类
public static JasperPrint execute(int[] hits, String query,String fields) {
itemMap = new HashMap<String, Item>();
fieldList=fields.split(",");
for (int i = 0; i < hits.length; i++) {
process(BisisApp.getRecordManager().getRecord(hits[i]));
}
StringBuffer buff = new StringBuffer();
buff.append("<report>\n");
List keys = new ArrayList();
keys.addAll(itemMap.keySet());
Collections.sort(keys);
Iterator fieldIDs = keys.iterator();
while (fieldIDs.hasNext()) {
String key = (String) fieldIDs.next();
Item item = (Item) itemMap.get(key);
buff.append(item.toString());
}
buff.append("\n</report>\n");
try {
JRXmlDataSource dataSource = new JRXmlDataSource(XMLUtils
.getDocumentFromString(buff.toString()), "/report/item");
Map param = new HashMap();
param.put("query", query);
JasperPrint jp = JasperFillManager
.fillReport(
CountFields.class
.getResource(
"/com/gint/app/bisis4/client/hitlist/groupview/CountFields.jasper")
.openStream(), param, dataSource);
return jp;
} catch (Exception ex) {
return null;
}
}
示例7: showReport
import net.sf.jasperreports.engine.data.JRXmlDataSource; //导入依赖的package包/类
/**
* Prikazuje ucitani izvestaj.
*/
public static void showReport(String xml,String fileName, Report report) {
HashMap<String, Object> params = new HashMap<String, Object>();
try {
for (ReportParam p : report.getReportSettings().getParams()){
if(p.getName().compareToIgnoreCase("subjasper")==0){
JasperReport subreport = (JasperReport) JRLoader.loadObject(ReportUtils.class
.getResource(p.getValue()).openStream());
params.put("subjasper", subreport);
}else{
params.put(p.getName(), p.getValue());
}
}
DefaultJasperReportsContext context = DefaultJasperReportsContext.getInstance(); //dodato zbog jaxena
JRPropertiesUtil.getInstance(context).setProperty("net.sf.jasperreports.xpath.executer.factory", "net.sf.jasperreports.engine.util.xml.JaxenXPathExecuterFactory");
params.put("period", getPeriod(fileName));
JRXmlDataSource dataSource = new JRXmlDataSource(XMLUtils
.getDocumentFromString(xml), "/report/item");
JasperPrint jp = JasperFillManager.fillReport(Report.class.getResource(
report.getJasper()).openStream(), params, dataSource);
BisisApp.getMainFrame().addReportFrame(report.getName(), jp);
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例8: runJasperReport
import net.sf.jasperreports.engine.data.JRXmlDataSource; //导入依赖的package包/类
public static JasperPrint runJasperReport(File aModelXMLFile, File aJRXMLFile) throws JRException,
FileNotFoundException {
String theFileName = aJRXMLFile.getAbsolutePath();
int p = theFileName.indexOf(".jrxml");
String theTemplateName = theFileName.substring(0, p) + ".jasper";
File theTemplateFile = new File(theTemplateName);
JasperDesign theDesign = JRXmlLoader.load(new FileInputStream(aJRXMLFile));
JRQuery theQuery = theDesign.getQuery();
String theQueryText = null;
if (theQuery != null) {
theQueryText = theQuery.getText();
}
if (StringUtils.isEmpty(theQueryText)) {
throw new RuntimeException("Cannot extract query from Jasper template");
}
Map<String, Object> theParams = new HashMap<>();
theParams.put(JRParameter.REPORT_LOCALE, Locale.getDefault());
String theSubreportDir = theTemplateFile.getParent();
if (!theSubreportDir.endsWith(File.separator)) {
theSubreportDir += File.separator;
}
theParams.put("SUBREPORT_DIR", theSubreportDir);
JRXmlDataSource theDataSource = new JRXmlDataSource(aModelXMLFile, theQueryText);
return JasperFillManager.fillReport(new FileInputStream(theTemplateFile), theParams,
theDataSource);
}
示例9: testGetXmlDataSource
import net.sf.jasperreports.engine.data.JRXmlDataSource; //导入依赖的package包/类
/**
* Test of getXmlDataSource method, of class Db.
*/
@Test
public void testGetXmlDataSource() throws Exception {
System.out.println("getxmlDataSource");
Config config = new Config();
config.dbType = DsType.xml;
config.dataFile = new File("target/test-classes/CancelAck.xml");
config.xmlXpath = "/CancelResponse/CancelResult/ID";
Db instance = new Db();
JRXmlDataSource jRXmlDataSource = instance.getXmlDataSource(config);
jRXmlDataSource.next();
// ToDo: don't know jet how to get any value out of it here.
// So just checking if object exists:
assertEquals(jRXmlDataSource.getClass().getCanonicalName(), "net.sf.jasperreports.engine.data.JRXmlDataSource");
}
示例10: GenerateByXML
import net.sf.jasperreports.engine.data.JRXmlDataSource; //导入依赖的package包/类
private void GenerateByXML() throws Exception {
if (this.m_strRootXPath.isEmpty()) {
throw new Exception("Root XPath is required.");
}
Map<String, Object> hm = new HashMap<String, Object>();
File file = new File(m_strDataSourceFile);
if (!file.canRead()) {
throw new Exception("Unable to read XML data source file.");
}
JRXmlDataSource jrxmlds = new JRXmlDataSource(file, m_strRootXPath);
exportOutputFile(JasperFillManager.fillReport(m_strJasperCompiledFile, hm, jrxmlds));
}
示例11: createSubreport
import net.sf.jasperreports.engine.data.JRXmlDataSource; //导入依赖的package包/类
private JasperReportBuilder createSubreport() throws JRException {
JasperReportBuilder report = report();
report.setLocale(Locale.ENGLISH)
.columns(
column4 = col.column("Column4", field("field4", type.stringType()).setDescription("@field4")),
column5 = col.column("Column5", field("field5", type.integerType()).setDescription("field5")),
column6 = col.column("Column6", field("field6", type.bigDecimalType())))
.setUseFieldNameAsDescription(false)
.setDataSource(new JRXmlDataSource(XmlReportTest.class.getResourceAsStream("data.xml"), "/data/row2"));
return report;
}
示例12: execute
import net.sf.jasperreports.engine.data.JRXmlDataSource; //导入依赖的package包/类
public static JasperPrint execute(int[]hits, String query) {
HashMap branchMap = new HashMap();
for (int i = 0; i < hits.length; i++) {
process(BisisApp.getRecordManager().getRecord(hits[i]), branchMap);
}
StringBuffer buff = new StringBuffer();
buff.append("<report>\n");
List keys = new ArrayList();
keys.addAll(branchMap.keySet());
Collections.sort(keys);
Iterator branchIDs = keys.iterator();
int sum = 0;
while (branchIDs.hasNext()) {
String key = (String)branchIDs.next();
Integer value = (Integer)branchMap.get(key);
buff.append(" <row><branch>");
buff.append(key);
/* buff.append(" - ");
buff.append(HoldingsDataCoders.getValue(HoldingsDataCoders.ODELJENJE_CODER, key));*/
buff.append("</branch><count>");
buff.append(value);
buff.append("</count></row>\n");
sum += value.intValue();
}
buff.append(" <row><branch>Ukupno primeraka</branch><count>");
buff.append(sum);
buff.append("</count></row>\n");
buff.append(" <row><branch>Ukupno zapisa</branch><count>");
buff.append(hits.length);
buff.append("</count></row>\n");
buff.append("</report>\n");
try {
JRXmlDataSource dataSource = new JRXmlDataSource(
XMLUtils.getDocumentFromString(buff.toString()), "/report/row");
Map param=new HashMap();
param.put("query", query);
JasperPrint jp = JasperFillManager.fillReport(
PogodciPoOgrancima.class.getResource(
"/com/gint/app/bisis4/client/hitlist/groupview/PogodciPoOgrancima.jasper")
.openStream(),param, dataSource);
return jp;
} catch (Exception ex) {
return null;
}
}
示例13: execute
import net.sf.jasperreports.engine.data.JRXmlDataSource; //导入依赖的package包/类
public static JasperPrint execute(int[] hits, String query) {
itemMap = new HashMap<String, Item>();
oldQuery = query;
int indexBI = query.indexOf("BI:");
int indexAP = query.indexOf("AP:");
if (indexAP != -1) {
odeljenjeQuery = oldQuery.substring(indexAP);
if (odeljenjeQuery.indexOf(" ")!= -1){
odeljenjeQuery = odeljenjeQuery.substring(3,odeljenjeQuery.indexOf(" ") );
}else{
odeljenjeQuery = odeljenjeQuery.substring(3);
}
}
if(!query.contains("BI:"))
return null;
query = query.substring(indexBI);
int indexS = query.indexOf(" ");
if (indexS != -1)
query = query.substring(0, indexS);
if (query.contains("*")) {
datefromQuery = query.substring(3).replace("*", ".*");
} else if (query.contains("?")) {
datefromQuery = query.substring(3).replace("?", ".*");
} else {
datefromQuery = query.substring(3);
}
datefromQuery=".*"+datefromQuery+".*";
for (int i = 0; i < hits.length; i++) {
process(BisisApp.getRecordManager().getRecord(hits[i]));
}
StringBuffer buff = new StringBuffer();
buff.append("<report>\n");
List keys = new ArrayList();
keys.addAll(itemMap.keySet());
Collections.sort(keys);
Iterator branchIDs = keys.iterator();
while (branchIDs.hasNext()) {
String key = (String) branchIDs.next();
Item item = (Item) itemMap.get(key);
buff.append(item.toString());
}
buff.append("</report>\n");
try {
JRXmlDataSource dataSource = new JRXmlDataSource(XMLUtils
.getDocumentFromString(buff.toString()), "/report/item");
Map param = new HashMap();
param.put("query", oldQuery);
JasperPrint jp = JasperFillManager
.fillReport(
PogodciPoInvNapomeni.class
.getResource(
"/com/gint/app/bisis4/client/hitlist/groupview/PogodciPoInvNapomeni.jasper")
.openStream(), param, dataSource);
return jp;
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
示例14: execute
import net.sf.jasperreports.engine.data.JRXmlDataSource; //导入依赖的package包/类
public static JasperPrint execute(int[] hits, String query) {
itemMap = new HashMap<String, Item>();
if(query.startsWith("DA:")){
if(query.contains("*")){
datefromQuery=query.substring(3).replace("*", "");
}else if(query.contains("?")){
datefromQuery=query.substring(3).replace("?", "");
}else{
datefromQuery=query.substring(3);
}
}
for (int i = 0; i < hits.length; i++) {
process(BisisApp.getRecordManager().getRecord(hits[i]));
}
StringBuffer buff = new StringBuffer();
buff.append("<report>\n");
List keys = new ArrayList();
keys.addAll(itemMap.keySet());
Collections.sort(keys);
Iterator branchIDs = keys.iterator();
while (branchIDs.hasNext()) {
String key = (String) branchIDs.next();
Item item = (Item) itemMap.get(key);
buff.append(item.toString());
}
buff.append("</report>\n");
try {
JRXmlDataSource dataSource = new JRXmlDataSource(XMLUtils
.getDocumentFromString(buff.toString()), "/report/item");
Map param = new HashMap();
param.put("query", query);
param.put("datum", datefromQuery);
if(query.startsWith("DA:")){
param.put("query", datefromQuery);
}
JasperPrint jp = JasperFillManager
.fillReport(
PogodciPoDatumuInventara.class
.getResource(
"/com/gint/app/bisis4/client/hitlist/groupview/BranchesPoDatumu.jasper")
.openStream(), param, dataSource);
return jp;
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
示例15: getReport
import net.sf.jasperreports.engine.data.JRXmlDataSource; //导入依赖的package包/类
private void getReport(){
try{
doc = makeDoc(getTfBegDate().getDate(), getTfEndDate().getDate());
if (doc != null){
if (getChbSave().isSelected()){
getManager().saveWarnings(warn_to_save, counters);
}
boolean cyr = false;
if (doc.getRoot().getCirilica() == 1){
cyr = true;
}
StringWriter sw = new StringWriter();
XmlOptions xmlOptions = new XmlOptions();
xmlOptions.setSavePrettyPrint();
doc.save(sw,xmlOptions);
JasperReport subreport = (JasperReport)JRLoader.loadObject(
WarningsFrame.class.getResource(
"/com/gint/app/bisis4/client/circ/warnings/jaspers/details.jasper").openStream());
JasperReport warning = (JasperReport)JRLoader.loadObject(
WarningsFrame.class.getResource(
"/com/gint/app/bisis4/client/circ/warnings/jaspers/warning.jasper").openStream());
Map params = new HashMap(2);
params.put("sub", subreport);
params.put("warning", warning);
// JRXmlDataSource ds = new JRXmlDataSource(XMLUtils
// .getDocumentFromString(sw.toString()), "/root/opomena");
//JRXmlDataSource ds = new JRXmlDataSource(new ByteArrayInputStream((sw.toString().getBytes())), "/root/opomena");
JRXmlDataSource ds = new JRXmlDataSource(doc.newInputStream(), "/root/opomena");
JasperPrint jp = JasperFillManager.fillReport(
WarningsFrame.class.getResource(
"/com/gint/app/bisis4/client/circ/warnings/jaspers/all.jasper").openStream(),
params, ds);
JRViewer jr = new JRViewer(jp);
getReportPanel().add(jr, java.awt.BorderLayout.CENTER);
String naslov = Utils.convert("Spisak " + ((WarningTypes)getCmbType().getSelectedItem()).getName() + " posaltih na dan " + new SimpleDateFormat("dd.MM.yyyy.").format(new Date()), cyr);
String rbr = Utils.convert("R.br.", cyr);
String bropomene = Utils.convert("Br.opomene", cyr);
String brclana = Utils.convert("Br.\u010dlana", cyr);
String ime = Utils.convert("Prezime i ime", cyr);
String datum = Utils.convert("Rok vra\u0107anja", cyr);
//String napomena = Utils.convert("Napomena", cyr);
Map paramslist = new HashMap(7);
paramslist.put("naslov", naslov);
paramslist.put("rbr", rbr);
paramslist.put("bropomene", bropomene);
paramslist.put("brclana", brclana);
paramslist.put("ime", ime);
paramslist.put("datum", datum);
//paramslist.put("napomena", napomena);
JRXmlDataSource dslist = new JRXmlDataSource(XMLUtils
.getDocumentFromString(sw.toString()), "/root/opomena");
JasperPrint jplist = JasperFillManager.fillReport(
WarningsFrame.class.getResource(
"/com/gint/app/bisis4/client/circ/warnings/jaspers/list.jasper").openStream(),
paramslist, dslist);
JRViewer jrlist = new JRViewer(jplist);
getReportListPanel().add(jrlist, java.awt.BorderLayout.CENTER);
}
}catch(Exception e){
e.printStackTrace();
}
}