- 浏览: 547404 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (740)
- css (4)
- jquery (8)
- javascript (23)
- html (0)
- uml (0)
- 设计模式 (1)
- 开发工具 (14)
- json (4)
- struts 1.x (3)
- spring (3)
- hibernate (6)
- struts 2.x (17)
- JFreechart (0)
- j2se (48)
- jsp (9)
- flex (22)
- 找工作 (1)
- 技术杂谈 (18)
- 网络编程 (5)
- io流 (1)
- ORACLE (15)
- 报表 (3)
- extjs (11)
- jpbm (2)
- swing (5)
- jspereports (3)
- sql (1)
- linux (15)
- ps (1)
- storm (4)
- hbase (8)
- li (0)
- python (1)
- hive (3)
- 机器学习 (1)
- hdfs (1)
- elasticsearch (1)
- hadoop 2.2 (5)
- hadoop (1)
最新评论
-
Tristan_S:
这个有点意思
ASM -
starryskydog:
程序修改detail band部分的样式 如内容字体大小 ...
使用jasperReport实现动态表头 -
samwong:
Good, so usefule
使用YUI Compressor压缩CSS/JS -
gc715409742:
能够告诉我怎么在web项目中使用YUI Compressor? ...
使用YUI Compressor压缩CSS/JS -
JsonTeye:
您好! 我看你的代码,我现在也在做动态报表,实现功能由用户自己 ...
使用jasperreport动态生成pdf,excel,html
项目里用到了jasperreport,平时都是用ireport来设计好报表模板直接使用就好了,但是碰到动态表头等情况就比较麻烦了,而且有些报表可能仅是针对一个数据表或者说一个实体对象的操作,对于这种报表一个个设计JRXML也比较麻烦,尝试了一下编程的方式来生成报表,只是个简单的测试。在网上找一些资料发现纯编程来写报表的相关内容很少,也是看了相关的API后才写了个例子。
ReportProcess.java是一个简单的用来构造、编译并导出报表的类。
Java代码
1.package jasper.test;
2.
3.import java.io.FileInputStream;
4.import java.io.InputStream;
5.import java.io.InputStreamReader;
6.
7.import net.sf.jasperreports.engine.JRException;
8.import net.sf.jasperreports.engine.JasperCompileManager;
9.import net.sf.jasperreports.engine.JasperExportManager;
10.import net.sf.jasperreports.engine.JasperFillManager;
11.import net.sf.jasperreports.engine.JasperPrint;
12.import net.sf.jasperreports.engine.JasperReport;
13.import net.sf.jasperreports.engine.design.JRDesignBand;
14.import net.sf.jasperreports.engine.design.JRDesignExpression;
15.import net.sf.jasperreports.engine.design.JRDesignField;
16.import net.sf.jasperreports.engine.design.JRDesignStaticText;
17.import net.sf.jasperreports.engine.design.JRDesignTextField;
18.import net.sf.jasperreports.engine.design.JasperDesign;
19.
20.public class ReportProcess {
21.
22. public static void main(String[] args) {
23. try {
24. JasperReport jp = getJasperReport();
25. InputStream in = new FileInputStream(
26. "src/test/java/jasper/test/Data.csv");// 换成自己目录
27. CsvDataSource csvDataSource = new CsvDataSource(
28. new InputStreamReader(in));
29. in.close();
30.
31. JasperPrint jpr = JasperFillManager.fillReport(jp, null,
32. csvDataSource);
33. JasperExportManager.exportReportToHtmlFile(jpr, "c:/test.html");// 写的时候随便指定了个查看的目录
34. } catch (Exception e) {
35. e.printStackTrace();
36. }
37. }
38.
39. public static JasperReport getJasperReport() throws JRException {
40. JasperDesign design = new JasperDesign();
41. design.setName("testReport");
42.
43. JRDesignBand title = new JRDesignBand();
44. title.setHeight(50);
45. JRDesignStaticText titleText = new JRDesignStaticText();
46. titleText.setText("test report");
47. titleText.setX(230);
48. titleText.setFontSize(20);
49. titleText.setHeight(50);
50. titleText.setWidth(100);
51. title.addElement(titleText);
52. design.setTitle(title);
53.
54. String[] headers = { "name", "age", "gender", "like" };
55. JRDesignBand columnHeader = new JRDesignBand();
56. columnHeader.setHeight(30);
57.
58. JRDesignBand detail = new JRDesignBand();
59. detail.setHeight(30);
60.
61. for (int i = 0; i < headers.length; i++) {
62. // add column headers
63. JRDesignStaticText staticText = new JRDesignStaticText();
64. staticText.setText(headers[i]);
65. staticText.setFontSize(16);
66. staticText.setHeight(30);
67. staticText.setWidth(50);
68. staticText.setX(50 * i);
69. columnHeader.addElement(staticText);
70.
71. // define fields
72. JRDesignField field = new JRDesignField();
73. field.setName(headers[i]);
74. field.setValueClass(String.class);
75. design.addField(field);
76.
77. // add text fields for displaying fields
78. JRDesignTextField textField = new JRDesignTextField();
79. JRDesignExpression expression = new JRDesignExpression();
80. expression.setText("$F{" + headers[i] + "}");
81. expression.setValueClass(String.class);
82. textField.setExpression(expression);
83. textField.setFontSize(14);
84. textField.setHeight(30);
85. textField.setWidth(50);
86. textField.setX(50 * i);
87. detail.addElement(textField);
88. }
89. design.setColumnHeader(columnHeader);
90. design.setDetail(detail);
91.
92. return JasperCompileManager.compileReport(design);
93. }
94.
95.}
package jasper.test;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.design.JRDesignBand;
import net.sf.jasperreports.engine.design.JRDesignExpression;
import net.sf.jasperreports.engine.design.JRDesignField;
import net.sf.jasperreports.engine.design.JRDesignStaticText;
import net.sf.jasperreports.engine.design.JRDesignTextField;
import net.sf.jasperreports.engine.design.JasperDesign;
public class ReportProcess {
public static void main(String[] args) {
try {
JasperReport jp = getJasperReport();
InputStream in = new FileInputStream(
"src/test/java/jasper/test/Data.csv");// 换成自己目录
CsvDataSource csvDataSource = new CsvDataSource(
new InputStreamReader(in));
in.close();
JasperPrint jpr = JasperFillManager.fillReport(jp, null,
csvDataSource);
JasperExportManager.exportReportToHtmlFile(jpr, "c:/test.html");// 写的时候随便指定了个查看的目录
} catch (Exception e) {
e.printStackTrace();
}
}
public static JasperReport getJasperReport() throws JRException {
JasperDesign design = new JasperDesign();
design.setName("testReport");
JRDesignBand title = new JRDesignBand();
title.setHeight(50);
JRDesignStaticText titleText = new JRDesignStaticText();
titleText.setText("test report");
titleText.setX(230);
titleText.setFontSize(20);
titleText.setHeight(50);
titleText.setWidth(100);
title.addElement(titleText);
design.setTitle(title);
String[] headers = { "name", "age", "gender", "like" };
JRDesignBand columnHeader = new JRDesignBand();
columnHeader.setHeight(30);
JRDesignBand detail = new JRDesignBand();
detail.setHeight(30);
for (int i = 0; i < headers.length; i++) {
// add column headers
JRDesignStaticText staticText = new JRDesignStaticText();
staticText.setText(headers[i]);
staticText.setFontSize(16);
staticText.setHeight(30);
staticText.setWidth(50);
staticText.setX(50 * i);
columnHeader.addElement(staticText);
// define fields
JRDesignField field = new JRDesignField();
field.setName(headers[i]);
field.setValueClass(String.class);
design.addField(field);
// add text fields for displaying fields
JRDesignTextField textField = new JRDesignTextField();
JRDesignExpression expression = new JRDesignExpression();
expression.setText("$F{" + headers[i] + "}");
expression.setValueClass(String.class);
textField.setExpression(expression);
textField.setFontSize(14);
textField.setHeight(30);
textField.setWidth(50);
textField.setX(50 * i);
detail.addElement(textField);
}
design.setColumnHeader(columnHeader);
design.setDetail(detail);
return JasperCompileManager.compileReport(design);
}
}
CsvDataSource.java是摘自JASER例子里的一个数据源实现,有现成的做例子的时候就拿来用了,用这个比较简单,不用写数据库那一堆。
Java代码
1.package jasper.test;
2.
3.import java.io.FileNotFoundException;
4.import java.io.IOException;
5.import java.io.Reader;
6.import java.util.List;
7.
8.import net.sf.jasperreports.engine.JRException;
9.import net.sf.jasperreports.engine.JRField;
10.import net.sf.jasperreports.engine.JRRewindableDataSource;
11.import au.com.bytecode.opencsv.CSVReader;
12.
13./**
14. *
15. * 这个类摘自JASPER带的一个例子里的CSV数据源实现。
16. *
17. */
18.public class CsvDataSource implements JRRewindableDataSource {
19. private CSVReader csvReader;
20. private List rows;
21. private int currentRowIndex = -1;
22. private int currentColIndex = 0;
23. private int totalRows;
24.
25. public CsvDataSource(Reader reader) {
26. try {
27. csvReader = new CSVReader(reader);
28. rows = csvReader.readAll();
29. totalRows = rows.size();
30. } catch (FileNotFoundException e) {
31. e.printStackTrace();
32. } catch (IOException e) {
33. e.printStackTrace();
34. }
35. }
36.
37. public boolean next() throws JRException {
38. boolean retVal = true;
39.
40. currentRowIndex++;
41. currentColIndex = 0;
42.
43. if (currentRowIndex >= totalRows) {
44. retVal = false;
45. }
46.
47. return retVal;
48. }
49.
50. public Object getFieldValue(JRField arg0) throws JRException {
51. String value = null;
52. String[] currentRow = (String[]) rows.get(currentRowIndex);
53.
54. value = currentRow[currentColIndex];
55. currentColIndex++;
56.
57. return value;
58. }
59.
60. public void moveFirst() throws JRException {
61. currentRowIndex = 0;
62. currentColIndex = 0;
63. }
64.}
package jasper.test;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Reader;
import java.util.List;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;
import net.sf.jasperreports.engine.JRRewindableDataSource;
import au.com.bytecode.opencsv.CSVReader;
/**
*
* 这个类摘自JASPER带的一个例子里的CSV数据源实现。
*
*/
public class CsvDataSource implements JRRewindableDataSource {
private CSVReader csvReader;
private List rows;
private int currentRowIndex = -1;
private int currentColIndex = 0;
private int totalRows;
public CsvDataSource(Reader reader) {
try {
csvReader = new CSVReader(reader);
rows = csvReader.readAll();
totalRows = rows.size();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public boolean next() throws JRException {
boolean retVal = true;
currentRowIndex++;
currentColIndex = 0;
if (currentRowIndex >= totalRows) {
retVal = false;
}
return retVal;
}
public Object getFieldValue(JRField arg0) throws JRException {
String value = null;
String[] currentRow = (String[]) rows.get(currentRowIndex);
value = currentRow[currentColIndex];
currentColIndex++;
return value;
}
public void moveFirst() throws JRException {
currentRowIndex = 0;
currentColIndex = 0;
}
}
Data.csv里的数据。
Java代码
1.jim,12,male,basketball
2.lily,13,female,dancing
3.david,23,male,swimming
4.su,23,female,running
jim,12,male,basketball
lily,13,female,dancing
david,23,male,swimming
su,23,female,running
结果大致是这个样子。
Java代码
1. test report
2.name age gender like
3.jim 12 male basketb
4.lily 13 female dancing
5.david 23 male swimmi
6.su 23 female running
test report
name age gender like
jim 12 male basketb
lily 13 female dancing
david 23 male swimmi
su 23 female running
这里就是个实验性的代码,但至少可以知道,我们可以通过一些手段来编程处理JASPER的报表。可以写得更完善一些,动态获取表头个数与内容,写QUERY查询,填充报表。
比如一张表有一部分表头是不定的,那就可以在程序中追加表头定义,追加字段定义等。
ReportProcess.java是一个简单的用来构造、编译并导出报表的类。
Java代码
1.package jasper.test;
2.
3.import java.io.FileInputStream;
4.import java.io.InputStream;
5.import java.io.InputStreamReader;
6.
7.import net.sf.jasperreports.engine.JRException;
8.import net.sf.jasperreports.engine.JasperCompileManager;
9.import net.sf.jasperreports.engine.JasperExportManager;
10.import net.sf.jasperreports.engine.JasperFillManager;
11.import net.sf.jasperreports.engine.JasperPrint;
12.import net.sf.jasperreports.engine.JasperReport;
13.import net.sf.jasperreports.engine.design.JRDesignBand;
14.import net.sf.jasperreports.engine.design.JRDesignExpression;
15.import net.sf.jasperreports.engine.design.JRDesignField;
16.import net.sf.jasperreports.engine.design.JRDesignStaticText;
17.import net.sf.jasperreports.engine.design.JRDesignTextField;
18.import net.sf.jasperreports.engine.design.JasperDesign;
19.
20.public class ReportProcess {
21.
22. public static void main(String[] args) {
23. try {
24. JasperReport jp = getJasperReport();
25. InputStream in = new FileInputStream(
26. "src/test/java/jasper/test/Data.csv");// 换成自己目录
27. CsvDataSource csvDataSource = new CsvDataSource(
28. new InputStreamReader(in));
29. in.close();
30.
31. JasperPrint jpr = JasperFillManager.fillReport(jp, null,
32. csvDataSource);
33. JasperExportManager.exportReportToHtmlFile(jpr, "c:/test.html");// 写的时候随便指定了个查看的目录
34. } catch (Exception e) {
35. e.printStackTrace();
36. }
37. }
38.
39. public static JasperReport getJasperReport() throws JRException {
40. JasperDesign design = new JasperDesign();
41. design.setName("testReport");
42.
43. JRDesignBand title = new JRDesignBand();
44. title.setHeight(50);
45. JRDesignStaticText titleText = new JRDesignStaticText();
46. titleText.setText("test report");
47. titleText.setX(230);
48. titleText.setFontSize(20);
49. titleText.setHeight(50);
50. titleText.setWidth(100);
51. title.addElement(titleText);
52. design.setTitle(title);
53.
54. String[] headers = { "name", "age", "gender", "like" };
55. JRDesignBand columnHeader = new JRDesignBand();
56. columnHeader.setHeight(30);
57.
58. JRDesignBand detail = new JRDesignBand();
59. detail.setHeight(30);
60.
61. for (int i = 0; i < headers.length; i++) {
62. // add column headers
63. JRDesignStaticText staticText = new JRDesignStaticText();
64. staticText.setText(headers[i]);
65. staticText.setFontSize(16);
66. staticText.setHeight(30);
67. staticText.setWidth(50);
68. staticText.setX(50 * i);
69. columnHeader.addElement(staticText);
70.
71. // define fields
72. JRDesignField field = new JRDesignField();
73. field.setName(headers[i]);
74. field.setValueClass(String.class);
75. design.addField(field);
76.
77. // add text fields for displaying fields
78. JRDesignTextField textField = new JRDesignTextField();
79. JRDesignExpression expression = new JRDesignExpression();
80. expression.setText("$F{" + headers[i] + "}");
81. expression.setValueClass(String.class);
82. textField.setExpression(expression);
83. textField.setFontSize(14);
84. textField.setHeight(30);
85. textField.setWidth(50);
86. textField.setX(50 * i);
87. detail.addElement(textField);
88. }
89. design.setColumnHeader(columnHeader);
90. design.setDetail(detail);
91.
92. return JasperCompileManager.compileReport(design);
93. }
94.
95.}
package jasper.test;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.design.JRDesignBand;
import net.sf.jasperreports.engine.design.JRDesignExpression;
import net.sf.jasperreports.engine.design.JRDesignField;
import net.sf.jasperreports.engine.design.JRDesignStaticText;
import net.sf.jasperreports.engine.design.JRDesignTextField;
import net.sf.jasperreports.engine.design.JasperDesign;
public class ReportProcess {
public static void main(String[] args) {
try {
JasperReport jp = getJasperReport();
InputStream in = new FileInputStream(
"src/test/java/jasper/test/Data.csv");// 换成自己目录
CsvDataSource csvDataSource = new CsvDataSource(
new InputStreamReader(in));
in.close();
JasperPrint jpr = JasperFillManager.fillReport(jp, null,
csvDataSource);
JasperExportManager.exportReportToHtmlFile(jpr, "c:/test.html");// 写的时候随便指定了个查看的目录
} catch (Exception e) {
e.printStackTrace();
}
}
public static JasperReport getJasperReport() throws JRException {
JasperDesign design = new JasperDesign();
design.setName("testReport");
JRDesignBand title = new JRDesignBand();
title.setHeight(50);
JRDesignStaticText titleText = new JRDesignStaticText();
titleText.setText("test report");
titleText.setX(230);
titleText.setFontSize(20);
titleText.setHeight(50);
titleText.setWidth(100);
title.addElement(titleText);
design.setTitle(title);
String[] headers = { "name", "age", "gender", "like" };
JRDesignBand columnHeader = new JRDesignBand();
columnHeader.setHeight(30);
JRDesignBand detail = new JRDesignBand();
detail.setHeight(30);
for (int i = 0; i < headers.length; i++) {
// add column headers
JRDesignStaticText staticText = new JRDesignStaticText();
staticText.setText(headers[i]);
staticText.setFontSize(16);
staticText.setHeight(30);
staticText.setWidth(50);
staticText.setX(50 * i);
columnHeader.addElement(staticText);
// define fields
JRDesignField field = new JRDesignField();
field.setName(headers[i]);
field.setValueClass(String.class);
design.addField(field);
// add text fields for displaying fields
JRDesignTextField textField = new JRDesignTextField();
JRDesignExpression expression = new JRDesignExpression();
expression.setText("$F{" + headers[i] + "}");
expression.setValueClass(String.class);
textField.setExpression(expression);
textField.setFontSize(14);
textField.setHeight(30);
textField.setWidth(50);
textField.setX(50 * i);
detail.addElement(textField);
}
design.setColumnHeader(columnHeader);
design.setDetail(detail);
return JasperCompileManager.compileReport(design);
}
}
CsvDataSource.java是摘自JASER例子里的一个数据源实现,有现成的做例子的时候就拿来用了,用这个比较简单,不用写数据库那一堆。
Java代码
1.package jasper.test;
2.
3.import java.io.FileNotFoundException;
4.import java.io.IOException;
5.import java.io.Reader;
6.import java.util.List;
7.
8.import net.sf.jasperreports.engine.JRException;
9.import net.sf.jasperreports.engine.JRField;
10.import net.sf.jasperreports.engine.JRRewindableDataSource;
11.import au.com.bytecode.opencsv.CSVReader;
12.
13./**
14. *
15. * 这个类摘自JASPER带的一个例子里的CSV数据源实现。
16. *
17. */
18.public class CsvDataSource implements JRRewindableDataSource {
19. private CSVReader csvReader;
20. private List rows;
21. private int currentRowIndex = -1;
22. private int currentColIndex = 0;
23. private int totalRows;
24.
25. public CsvDataSource(Reader reader) {
26. try {
27. csvReader = new CSVReader(reader);
28. rows = csvReader.readAll();
29. totalRows = rows.size();
30. } catch (FileNotFoundException e) {
31. e.printStackTrace();
32. } catch (IOException e) {
33. e.printStackTrace();
34. }
35. }
36.
37. public boolean next() throws JRException {
38. boolean retVal = true;
39.
40. currentRowIndex++;
41. currentColIndex = 0;
42.
43. if (currentRowIndex >= totalRows) {
44. retVal = false;
45. }
46.
47. return retVal;
48. }
49.
50. public Object getFieldValue(JRField arg0) throws JRException {
51. String value = null;
52. String[] currentRow = (String[]) rows.get(currentRowIndex);
53.
54. value = currentRow[currentColIndex];
55. currentColIndex++;
56.
57. return value;
58. }
59.
60. public void moveFirst() throws JRException {
61. currentRowIndex = 0;
62. currentColIndex = 0;
63. }
64.}
package jasper.test;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Reader;
import java.util.List;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;
import net.sf.jasperreports.engine.JRRewindableDataSource;
import au.com.bytecode.opencsv.CSVReader;
/**
*
* 这个类摘自JASPER带的一个例子里的CSV数据源实现。
*
*/
public class CsvDataSource implements JRRewindableDataSource {
private CSVReader csvReader;
private List rows;
private int currentRowIndex = -1;
private int currentColIndex = 0;
private int totalRows;
public CsvDataSource(Reader reader) {
try {
csvReader = new CSVReader(reader);
rows = csvReader.readAll();
totalRows = rows.size();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public boolean next() throws JRException {
boolean retVal = true;
currentRowIndex++;
currentColIndex = 0;
if (currentRowIndex >= totalRows) {
retVal = false;
}
return retVal;
}
public Object getFieldValue(JRField arg0) throws JRException {
String value = null;
String[] currentRow = (String[]) rows.get(currentRowIndex);
value = currentRow[currentColIndex];
currentColIndex++;
return value;
}
public void moveFirst() throws JRException {
currentRowIndex = 0;
currentColIndex = 0;
}
}
Data.csv里的数据。
Java代码
1.jim,12,male,basketball
2.lily,13,female,dancing
3.david,23,male,swimming
4.su,23,female,running
jim,12,male,basketball
lily,13,female,dancing
david,23,male,swimming
su,23,female,running
结果大致是这个样子。
Java代码
1. test report
2.name age gender like
3.jim 12 male basketb
4.lily 13 female dancing
5.david 23 male swimmi
6.su 23 female running
test report
name age gender like
jim 12 male basketb
lily 13 female dancing
david 23 male swimmi
su 23 female running
这里就是个实验性的代码,但至少可以知道,我们可以通过一些手段来编程处理JASPER的报表。可以写得更完善一些,动态获取表头个数与内容,写QUERY查询,填充报表。
比如一张表有一部分表头是不定的,那就可以在程序中追加表头定义,追加字段定义等。
发表评论
-
Exception starting filter struts2java.lang.NoClassDefFoundError: org/apache/comm
2011-10-28 08:49 1364遇到个启动Tomcat的错误。错误类型是: 严重: Ex ... -
关于异常positioned update are not supported总结
2010-12-12 22:52 2060今天项目中遇到了positioned update are n ... -
Struts2 如何获取Request,Session对象
2010-10-19 10:34 1457Struts2 如何获取Request,Session对象 ... -
Jasperreport+ireport 实践操作及web应用
2010-08-08 09:10 1910Jasperreport+ireport 实践操 ... -
Struts2的基本流程
2010-08-03 11:17 1228Struts2的基本流程 大致上,Struts2框架由三个 ... -
动态表头
2010-08-02 23:19 1276最近在我公司drp(运营分销系统)开发中,需要大量报表,由于本 ... -
运行struts2时又出现问题了,本来是用通配符的,却出现了如下错误:
2010-08-02 18:14 1167运行struts2时又出现问题了,本来是用通配符的,却出现了如 ... -
Unable to instantiate Action(关于struts2.0异常)
2010-08-02 17:57 1591Unable to instantiate Action(关于 ... -
Jasper Report用户手册
2010-08-02 11:32 1451Jasper Report用户手册... i version1 ... -
iReport学习笔记——动态报表
2010-08-01 23:29 1735iReport学习笔记——动态报表 最近一直在研究jaspe ... -
JasperReport学习笔记2-创建简单的报表例子
2010-08-01 21:21 1922JasperReport学习笔记2-创建简单的报表例子 一, ... -
log4j error
2010-07-27 19:17 749在强调可重用组件开发的今天,除了自己从头到尾开发一个可重用的日 ... -
log4j:WARN Please initialize the log4j system properly
2010-07-27 18:49 1637log4j:WARN Please initialize th ... -
Struts2的类型转换器
2010-07-27 17:53 811Struts2的类型转换器 一、概述 在B/S应用中,将字 ... -
Struts2的常量详解
2010-07-27 17:51 758Struts2的常量详解 通常struts2加载strut ... -
Unable to load configuration
2010-07-23 09:18 1070问题解决:Unable to load configurati ...
相关推荐
**JasperReport动态生成报表** JasperReport是一款强大的开源报表工具,主要用于生成各种复杂的静态和动态报表。它基于Java,可以很好地与Java应用程序、Web应用和企业级应用集成,提供丰富的报表设计和灵活的数据...
这种动态生成报表的方法可以极大地提高报表的灵活性和用户体验,使得用户可以根据自己的业务需求定制视图,而无需开发者每次都进行代码修改。 实现动态报表生成通常涉及以下几个关键技术点: 1. 字段选择界面:...
XML操作RDLC动态生成报表是一种高效且灵活的方法,可以满足对数据可视化的需求。本文将深入探讨如何使用C#编程语言来实现RDLC(Report Definition Language Client)自定义报表,并结合XML数据源进行动态生成。 ...
本话题将深入探讨如何使用`RDLC`和`XML`来动态生成报表。 `RDLC`报表是一种基于控件的报表设计,它可以在Visual Studio中进行编辑,支持多种数据源,包括SQL Server数据库、XML数据源、甚至自定义数据源。报表设计...
本主题聚焦于使用C#动态生成RDLC(Report Definition Language Client)报表,这是一种由Microsoft开发的用于本地报表的XML格式,广泛应用于Windows Forms和ASP.NET应用程序。 RDLC报表的优势在于它允许开发者在...
在动态生成报表时,我们可能需要将对象的状态(如报表设计或用户配置)保存到XML文件,以便稍后恢复。C#提供了多种序列化机制,如BinaryFormatter、SoapFormatter,以及更现代的XmlSerializer。在本例中,...
例如,代码段 "ds1=split($p1,",")" 可能指的是通过某种方式(如split函数)对参数$p1进行处理,将其分割成一个数组或列表,之后可能会用到这个结果来动态生成报表中的列。 在FineReport中设计动态列报表,通常需要...
动态生成报表的核心在于实时更新数据源。以下是如何在代码中实现这一过程: 1. **建立数据库连接**:使用适当的连接字符串和驱动程序(如OleDbConnection对于Access数据库)打开数据库连接。 2. **执行查询**:...
9. **错误处理与调试**:在动态生成报表过程中,可能会遇到各种错误,如数据源连接问题、表达式错误等。因此,良好的错误处理和调试机制是必不可少的。 10. **性能优化**:动态生成大量数据的报表时,需要注意性能...
在IT行业中,动态列生成报表是一项重要的数据可视化技术,它允许用户根据实际需求自定义报表中的列展示,提高数据分析的灵活性和效率。本篇将深入探讨动态列生成报表的相关知识点,包括其概念、实现方式、适用场景...
本资源“C#动态水晶报表”专注于在C# WinForm应用程序中实现动态生成报表的功能,这在实际开发中具有很高的实用价值。 首先,我们来理解“动态水晶报表”的概念。动态报表是指根据用户输入或系统参数实时生成的报表...
- 动态生成报表列时需确保处理好数据类型转换,以防止因数据类型不匹配引发的异常。 - 避免在高并发环境下频繁创建和销毁水晶报表实例,这可能导致性能问题。可以考虑使用报表缓存或池化策略来优化。 总结,Asp.Net...
为了解决这些问题,需要一种能够动态生成报表的技术,这就是本文要介绍的Java生成PDF报表技术。 二、iText简介 iText是一个著名的开放源码的站点sourceforge的一个项目,是用于生成PDF文档的一个Java类库。通过...
- 动态报表可以根据用户的输入参数或运行时的数据源动态生成报表结构和内容。 2. **创建动态水晶报表** - 使用水晶报表设计器创建报表模板,可以预定义布局和样式,但不固定数据字段,以适应不同数据源。 - 在...
动态报表是指在运行时根据用户输入或系统配置动态生成报表的过程。这涉及到多个步骤: 1. **数据准备**:根据报表需求从数据源获取数据。 2. **报表布局设计**:定义报表的基本结构和样式,如字段布局、表格样式等...
生成器根据这些信息动态生成报表。 6. **报表生成器的优势**: - 程序员无需关注Excel操作的细节,专注于数据源的组装。 - 模板设计直观,所见即所得,报表样式与模板一致。 - 维护便利,模板改动不影响程序主体...
在.NET环境中,我们可以通过编程方式来创建这些报表,使得自动化和动态生成报表成为可能。 .NET Framework提供了多种库来帮助开发者生成Excel报表,其中最著名的有: 1. **EPPlus**: 这是一个开源库,支持读写...