java应用程序中如何做报表打印界面 如题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以用开源的报表工具实现,jf,ireport都可以。网址:wwww.open-open.com package mypro;/** * <p>Title: </p> * * <p>Description: </p> * * <p>Copyright: Copyright (c) 2008</p> * * <p>Company: </p> * * @author 张栋芳 * @version 1.0该类为写入到网页中的功能实现 */import java.util.*;import java.io.*;import javax.swing.*;public class PrintHtml { private Vector veData; private File file; private FileOutputStream fos; private String allPane; private String path; //保存路径 private String fileName; //文件名 public PrintHtml() {}; private String type; public PrintHtml(Vector veDate, String path, String fileName, String type) { this.veData = veDate; //要写入网页中的Vector对象 this.path = path; this.type = type; this.fileName = fileName; } /*返回值表示是否写入成功or写入完毕 * *colum写入以表格形式中的字段名 *text表格标题 *Vector veColum列名 *allPane拼截之后的内容 */ public boolean writeHtml(Vector veColum) { /* *选择写入的地 */ try { fileName = fileName + "/" + path; String pane = getPanel(veColum); byte[] all = new byte[pane.length()]; if (!fileName.endsWith(type)) { //判断用户是否设置扩展名 fileName = fileName.concat(type); } //System.out.println(fileName); JOptionPane.showMessageDialog(null, "请查看" + fileName); all = pane.getBytes(); fos = new FileOutputStream(fileName); fos.write(all); fos.close(); } catch (Exception ex) { } return true; } private String getPanel(Vector veColum) { String str = "<html><head><title>2008Vista人事管理系统报表打印</title></head><body><marquee><font size='12px' color='#3399FF'>欢迎使用2008Vista人事管理系统报表功能</font></marquee><br><table border='2' align='center' bordercolor='#6699FF' width='800'><br><caption ><font size='10px' color='#00FF00'>" + path + "</font></caption><tr>"; for (int i = 0; i < veColum.size(); i++) { str = str + "<td>" + (veColum.get(i)) + "</td>"; } str = str + "</tr><tr>"; for (int n = 0; n < veData.size(); n++) { Vector voData = (Vector) veData.get(n); for (int j = 0; j < voData.size(); j++) { str = str + "<td>" + voData.get(j) + "</td>"; } str = str + "</tr>"; } String end = "</table></body></html>"; return str + end; }}你看下这个呀,生成html的文件 关于简单的GUI问题 问个简单问题!! 问一个关于界面和逻辑交互的问题 谁用过 ofbiz 做过 checkbox的例子,会的请进 输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。 poi操作excel问题 高分求解 关于动态的创建对象,这样的该怎么实现?谢谢。 java中的打印预览 如何用Applet调用EXECLE文件 用JApplet and Batik開發SVG的問題 怎么写java来备份和还原SQL Server 2000
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2008</p>
*
* <p>Company: </p>
*
* @author 张栋芳
* @version 1.0该类为写入到网页中的功能实现
*/
import java.util.*;
import java.io.*;
import javax.swing.*;public class PrintHtml {
private Vector veData;
private File file;
private FileOutputStream fos;
private String allPane;
private String path; //保存路径
private String fileName; //文件名
public PrintHtml() {};
private String type;
public PrintHtml(Vector veDate, String path, String fileName, String type) {
this.veData = veDate; //要写入网页中的Vector对象
this.path = path;
this.type = type;
this.fileName = fileName;
} /*返回值表示是否写入成功or写入完毕
*
*colum写入以表格形式中的字段名
*text表格标题
*Vector veColum列名
*allPane拼截之后的内容
*/
public boolean writeHtml(Vector veColum) {
/*
*选择写入的地
*/
try {
fileName = fileName + "/" + path;
String pane = getPanel(veColum);
byte[] all = new byte[pane.length()];
if (!fileName.endsWith(type)) { //判断用户是否设置扩展名
fileName = fileName.concat(type);
}
//System.out.println(fileName);
JOptionPane.showMessageDialog(null, "请查看" + fileName);
all = pane.getBytes();
fos = new FileOutputStream(fileName);
fos.write(all);
fos.close();
}
catch (Exception ex) {
}
return true;
} private String getPanel(Vector veColum) {
String str = "<html><head><title>2008Vista人事管理系统报表打印</title></head><body><marquee><font size='12px' color='#3399FF'>欢迎使用2008Vista人事管理系统报表功能</font></marquee><br><table border='2' align='center' bordercolor='#6699FF' width='800'><br><caption ><font size='10px' color='#00FF00'>" +
path + "</font></caption><tr>";
for (int i = 0; i < veColum.size(); i++) {
str = str + "<td>" + (veColum.get(i)) + "</td>";
}
str = str + "</tr><tr>";
for (int n = 0; n < veData.size(); n++) {
Vector voData = (Vector) veData.get(n);
for (int j = 0; j < voData.size(); j++) {
str = str + "<td>" + voData.get(j) + "</td>";
}
str = str + "</tr>";
}
String end = "</table></body></html>";
return str + end;
}
}
你看下这个呀,生成html的文件