java报表开发询问

realminmin 2009-04-04 09:58:59
java有什么工具用来抓取excel文件的内容比较强,网上资料也比较多,最后讲抓取的内容再输出成EXCEL文件或者doc文件
谁能给出这方面的工具和相关教程,本人重分酬谢!非常紧急,所以自己上论坛问下!
...全文
271 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
ONE_DATA 2009-04-10
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 weilingfeng 的回复:]
FineReport怎么用?
[/Quote]

是现成的一款报表工具 下了就用咯 反正还有帮助文档的 可以进行二次开发什么的
关键是不需要你写代码 不然不烦死了啊
kelvin_yuwenjing 2009-04-10
  • 打赏
  • 举报
回复
路过,学习下
realminmin 2009-04-09
  • 打赏
  • 举报
回复

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;

import jxl.Sheet;
import jxl.Workbook;
import jxl.WorkbookSettings;
import jxl.read.biff.BiffException;

/**
*
*
* @author terry.xu
*
*/
public class JExcel {
public static void main(String[] args) {
try {

rename();
// generateHtml();
String contents[][] = new String[100][100];
// StringHelper.UNICODE_ENCODING="UTF-16LE";
WorkbookSettings workbookSettings = new WorkbookSettings();
workbookSettings.setEncoding("ISO-8859-1");
Workbook book = Workbook.getWorkbook(new File("d:/test.xls"),
workbookSettings);
Sheet[] sheets = book.getSheets();
for (int i = 0; i < sheets.length; i++) {
System.out.println(sheets[i].getName());
}

Sheet sheet = book.getSheet("Sheet1");
String content = null;
for (int i = 0; i < 100; i++) {

for (int j = 0; j < 100; j++) {
try {
content = sheet.getCell(j, i).getContents();

if(content!=null&&!"".equals(content))
contents[i][j] = content;

} catch (RuntimeException e) {

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

}

}
}
show(contents);
generateHtml(contents);
book.close();
rename();
} catch (BiffException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

private static void generateHtml(String contents[][]) {
StringBuffer path = new StringBuffer("d:/");
String name = "test";
String content = "hahaahahah";
File file2 = new File(path.append(name + ".html").toString());

StringBuilder sb = new StringBuilder();

try {
file2.createNewFile();// 创建文件
sb.append("<html><head><title>Html Test</title></head><body>");
sb.append("<div align='center'>");
sb.append("<p><strong>");
sb.append(contents[0][0]);
sb.append("</strong></p>");

sb.append("<table width=1000 border=1>");
String temp = null;
for (int i = 0; i < 10; i++) {

sb.append("<tr>");
for (int j = 0; j < 10; j++) {
temp = contents[i][j];
if (temp != null) {
sb.append("<td>");
sb.append(temp);
sb.append("</td>");
} else {
sb.append("<td width=");
sb.append("100 align=center");
sb.append(">");
sb.append(" ");
sb.append("</td>");
}
}
sb.append("</tr>");
}
sb.append("</table>");

sb.append("</div>");
sb.append("</body></html>");

PrintStream printStream = new PrintStream(new FileOutputStream(
file2));

printStream.println(sb.toString());// 将字符串写入文件



} catch (IOException e) {

e.printStackTrace();
}


}

private static void show(String str[][]) {
for (int i = 0; i < 100; i++)
for (int j = 0; j < 100; j++) {
if (str[i][j] != null)
System.out.println(str[i][j]);
}
}
public static void rename(){

String path = "d:/";
File rootdir = new File(path);
File target = null;
File toChange = null;

String names[] = rootdir.list();
for(int i = 0; i < names.length; i++) {

String name = names[i].replace("html","doc");
target = new File(path+"/"+ names[i]);
toChange = new File(path +"/"+name);

int j = 0;
if(target.exists() && !toChange.exists()) {
target.renameTo(toChange);

}

}


}
}
weilingfeng 2009-04-09
  • 打赏
  • 举报
回复
FineReport怎么用?
ONE_DATA 2009-04-09
  • 打赏
  • 举报
回复
试试Java开发的一款报表工具FineReport
这个可以导入到FineReport的报表设计器 也可以在设计器里做好了再导出成word excel和pdf格式
starry 2009-04-06
  • 打赏
  • 举报
回复
使用iReport工具
starry 2009-04-06
  • 打赏
  • 举报
回复
使用iReport工具
realminmin 2009-04-06
  • 打赏
  • 举报
回复
那用java生成doc文件用什么好啊
great1681 2009-04-06
  • 打赏
  • 举报
回复
用apache poi 读取excel文件很方便
用三个循环遍历就行了: 第一层是sheet循环,然后是行循环,最后是单元格循环.
1.package com.jie.java;   
2.
3.import java.io.File;
4.import java.io.FileInputStream;
5.
6.import org.apache.poi.hssf.usermodel.HSSFRow;
7.import org.apache.poi.hssf.usermodel.HSSFSheet;
8.import org.apache.poi.hssf.usermodel.HSSFWorkbook;
9.
10.public class ExcelRead {
11.
12. /**
13. * @param args
14. */
15. public static void main(String[] args) {
16. // TODO Auto-generated method stub
17.
18. try{
19. FileInputStream is = new FileInputStream(new File("c:/最终成绩.xls"));
20. HSSFWorkbook wb=new HSSFWorkbook(is);
21.
22. int sheetNum=wb.getNumberOfSheets();
23.
24. for(int i=0;i<sheetNum;i++)
25. {
26. HSSFSheet childSheet = wb.getSheetAt(i);
27. int rowNum = childSheet.getLastRowNum();
28.
29. for(int j=0;j<rowNum;j++)
30. {
31. HSSFRow row = childSheet.getRow(j);
32. int cellNum=row.getLastCellNum();
33.
34. for(int k=0;k<cellNum;k++)
35. {
36. System.out.print(row.getCell(k).toString()+" ");
37. }
38. System.out.println();
39. }
40.
41. }
42. }catch(Exception e)
43. {
44. e.printStackTrace();
45. }
46.
47. }
48.
49.}
realminmin 2009-04-06
  • 打赏
  • 举报
回复
d
realminmin 2009-04-05
  • 打赏
  • 举报
回复
详细点的,不要官网,最好是专门做的专题或者教程
Eric_Yu_Nupt 2009-04-05
  • 打赏
  • 举报
回复
http://poi.apache.org
realminmin 2009-04-05
  • 打赏
  • 举报
回复
我知道POI,有谁有详细点的资料,或者在线教程等等,谢谢!
C-H-M 2009-04-04
  • 打赏
  • 举报
回复
不错,这个。我也关注一下。
moonjaya 2009-04-04
  • 打赏
  • 举报
回复
学习。。顶你下
liuying2500 2009-04-04
  • 打赏
  • 举报
回复
恩,poi我用过,感觉还不错
quanjinzhang 2009-04-04
  • 打赏
  • 举报
回复
你看看Apache的开源API:POI工具,网站上http://poi.apache.org上有说明,或者下载POI的文档也可以离线学习。

81,076

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧