在JBuilder中怎么使用水晶报表(Crystal Reports)?

wqaihw 2007-01-12 11:59:03
我刚刚接触JBuilder,想用水晶报表做一个报表,不知道怎么做???请教大家????
...全文
677 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
yuly888 2007-09-30
  • 打赏
  • 举报
回复
不知道LZ有没有实现了呢?
nickzou2013 2007-06-21
  • 打赏
  • 举报
回复
我怎么沒有看見使用方法的介紹呢?
JAVANND 2007-05-31
  • 打赏
  • 举报
回复
closeAll();
}catch(SQLException e){

}
}
public void ReportDet2(String st){
try{
getStmt();
String sql22="select * from report_table2 where no1='"+st+"' order by id";
rs=stmt.executeQuery(sql22);
saleSubLedger1=new String[ku1][14];
for(int k=0;k<ku1;k++){
for(int h=0;h<14;h++){
saleSubLedger1[k][h] = "";
}
}
int i1=0;
String strku="";
while(rs.next()){
saleSubLedger1[i1][0]="" + rs.getString("no1");
saleSubLedger1[i1][1]="" + rs.getString("itemno");
saleSubLedger1[i1][2]="" + rs.getString("itemname");
saleSubLedger1[i1][3]="" + rs.getString("yn");
saleSubLedger1[i1][4]= "" +rs.getString("itemmem");
saleSubLedger1[i1][5]="" +rs.getString("packnum");
saleSubLedger1[i1][6]=""+rs.getDouble("gross");
saleSubLedger1[i1][7]=""+rs.getDouble("tare");
saleSubLedger1[i1][8]=""+rs.getDouble("num");
saleSubLedger1[i1][9]=""+rs.getString("huowei");
saleSubLedger1[i1][10]=""+rs.getString("mem");
saleSubLedger1[i1][11]=""+rs.getDouble("price");
saleSubLedger1[i1][12]=""+rs.getDouble("price1");
strku=rs.getString("cgno");
saleSubLedger1[i1][13]=strku;
i1+=1;
}
saleLedger10=strku;
closeAll();
}catch(SQLException e){

}
}
public void ReportSum2(String st){
try{

getStmt();
String sqlt1="select sum(gross) as a11,sum(tare) as a12,sum(num) as a13,sum(price1) as a14 from report_table2 where no1='"+st+"'";
rs=stmt.executeQuery(sqlt1);
if(rs.next()){
su3=rs.getDouble("a13");
su4=rs.getDouble("a14");
}
su1=Math.round(su1*10000);
su1=su1/10000;
su2=Math.round(su2*10000);
su2=su2/10000;
su3=Math.round(su3*10000);
su3=su3/10000;
su2=su1-su3;
su2=Math.round(su2*10000);
su2=su2/10000;
su4=Math.round(su4*100);
su4=su4/100;
closeAll();
}catch(SQLException e){
}
}
public void Reportfield3(String st){
try{
getStmt();
String sql212="select * from report_table3 where no1='"+st+"' order by id";
rs=stmt.executeQuery(sql212);
ku2=0;
while(rs.next()){
ku2+=1;
}
closeAll();
saleSubLedger2=new String[ku2][8];
}catch(SQLException e){
}
}
public void ReportDet3(String st){
try{
getStmt();
String sql222="select * from report_table3 where no1='"+st+"' order by id";
rs=stmt.executeQuery(sql222);
int i2=0;
while(rs.next()){
saleSubLedger2[i2][0]=""+rs.getString("no1");
saleSubLedger2[i2][1]=""+rs.getString("type1");
saleSubLedger2[i2][2]=""+rs.getDouble("num");
saleSubLedger2[i2][3]=""+rs.getString("pcs1");
saleSubLedger2[i2][4]=""+rs.getDouble("pcsnum");
saleSubLedger2[i2][5]=""+rs.getString("pcs2");
saleSubLedger2[i2][6]=""+rs.getDouble("total");
saleSubLedger2[i2][7]=""+rs.getString("mem");
i2+=1;
}
closeAll();
}catch(SQLException e){

}
}
public void ReportSum3(String st){
try{
getStmt();
String sqlt1="select sum(total) as a1 from report_table3 where no1='"+st+"'";
rs=stmt.executeQuery(sqlt1);
if(rs.next()){
sut3=rs.getDouble("a1");
}
sut3=Math.round(sut3*10000);
sut3=sut3/10000;
closeAll();
}catch(SQLException e){
}
}
/** 打印页面的方法 */
public void drawPages(Graphics2D g2){
if(isFirstPage){

drawFirstPage(g2);
}else{
drawOtherPages(g2,printPage);
}
}
/** 打印第1页的方法 */
public String checkChart(String str) {//转化汉字字体为普通字体
try{
trn = str;
byte bytes[];
bytes = trn.getBytes("ISO8859_1");
trn = new String(bytes, "GBK");
}catch(Exception e){
}
return trn;
}

public void drawFirstPage(Graphics2D g2){
//设置字体
g2.setFont(font16);
//显示销售单
barcode.setSize(barcode.WIDTH,barcode.HEIGHT);
barcode.qWe = BarCode1.q7E8; //code 39--->q1W2 q7E8--code 128 e3R4-->code 39EXT l9Z0---->CODE 93
g2.drawString("工 厂 收 货 报 告", 200,40); //x=173 ;y=80;
g2.setFont(font11);
g2.drawString("第 1 页 共 "+pageCount+" 页", 450, 20);
g2.drawString("收货日期:"+saleLedger1+" 来源:"+saleLedger12+" 封条号:"+saleLedger3,40,65);
g2.drawString("落地号:",360,65); //后面打印出落地号条码
// barcode.setW2e("C");
barcode.setRFv(0.5D);
barcode.setRTy(false);

barcode.wEr=saleLedger0; //落地号
// JOptionPane.showMessageDialog(null,"itemno1="+saleSubLedger[i][0]);
barcode.paint(g2.create(430,45,180,45));
// JOptionPane.showMessageDialog(null,"saleLedger10="+saleLedger10 +" saleLedger2="+saleLedger2);
if(saleLedger2.trim().length()>0){
g2.drawString("INV柜号: " + saleLedger2+" "+saleLedger11, 40, 90);
}else{
g2.drawString("货柜号: "+saleLedger10+" "+saleLedger11 , 40, 90);
}


JAVANND 2007-05-31
  • 打赏
  • 举报
回复
厂收货报告头高度为80
sumHeight+=((ku+3)+3+(ku2+2))*tableLineHeight+(tableLineHeight+25)*ku1+1*20+60;
sumtotal=((ku+3)+(ku2+2)+2)*tableLineHeight+21+60+20; //除了实际收货显示的高度
int tttn=(tableLineHeight+25)*ku1; //实际收货总高度
int kkn=(int)(700-sumtotal)/(tableLineHeight+25);
kkk=kkn;
pageCount+=1;
int kuu=(int)(ku1-kkn)/14;
if(ku1-kkn-kuu*14>0){
pageCount+=kuu+1;
}else{
pageCount+=kuu;
}
if(pageCount>1){
sumtotal+=3*tableLineHeight; //实际收货的字样头及合计
if(sumtotal<720){
tt2=1; //表示实际收货的字样及头与合计可以在第一页中显示
for(int i=1;i<=ku1;i++){
sumtotal+=tableLineHeight+25;
if(sumtotal>720){
tt1=i;//第一页显示实际收货的总记录数
break;
}
}
}else{
tt2=2; //表示在第二页中显示
tt1=ku1;
}
}else{
tt1=ku1;
tt2=1;
}
}
protected void getStmt()throws SQLException{//数据库的连接
if(con== null)
con = ConnectionPool.getConnection();
if(stmt == null)
stmt = con.createStatement();
}
protected void closeAll()throws SQLException{//关闭所有与数据库的连接
if(rs != null){
rs.close();
rs = null;
}
if(stmt != null){
stmt.close();
stmt = null;
}
if(pstmt != null){
pstmt.close();
pstmt = null;
}
if(!this.isTransaction && con != null)
ConnectionPool.returnConnection(con);
}

public void Reportfield(String st){
try{
String sql="select * from reporthead where no1='"+st+"'";
rs=stmt.executeQuery(sql);
if(rs.next()){
su1=rs.getDouble("cgross");
saleLedger10=""+rs.getString("cn");
saleLedger11=rs.getString("mem");
saleLedger12=rs.getString("laiyuan");
saleLedger0=rs.getString("no1");
saleLedger1=rs.getString("date1");
saleLedger2=rs.getString("cn1");
saleLedger3=rs.getString("sn");
saleLedger4=rs.getString("changer");
saleLedger5=rs.getString("wt");
saleLedger6=rs.getString("itemerr");
saleLedger7=rs.getString("claim");
saleLedger8=rs.getString("date2");
saleLedger9=rs.getString("comid");

}
closeAll();
}catch(SQLException e){
}
}
public void Reportfield1(String st){
try{
String sql2="select * from report_table1 where no1='"+st+"' order by id";
getStmt();
rs=stmt.executeQuery(sql2);
ku=0;
while(rs.next()){
ku+=1;
}
closeAll();
}catch(SQLException e){
}
}
public void ReportDet1(String st){
try{
getStmt();
2007-5-18日注释,加入下一行
String sql1="select report_table1.*,ReportInput_table.name1 from report_table1,reporthead,ReportInput_table where report_table1.no1='"+st+"' and report_table1.no1=reporthead.no1 and reporthead.cno=ReportInput_table.comid and report_table1.itemname=ReportInput_table.name2 order by report_table1.id";
rs=stmt.executeQuery(sql1);
int i=0;
double ttyn=0;
saleSubLedger=new String[ku][9]; //2007-5-18 将8改为9 主要是用来加入来单英文名称
while(rs.next()){
saleSubLedger[i][0]=""+rs.getString("no1");
saleSubLedger[i][1]=""+rs.getString("itemname");
saleSubLedger[i][8]=""+rs.getString("name1");
saleSubLedger[i][2]=""+rs.getString("packnum");
saleSubLedger[i][3]=""+rs.getDouble("gross");
saleSubLedger[i][4]=""+rs.getDouble("tare");
ttyn=rs.getDouble("num");
ttyn=Math.round(ttyn*10000);
ttyn=ttyn/10000;
saleSubLedger[i][5]=""+ttyn;
saleSubLedger[i][6]=""+rs.getDouble("price");
saleSubLedger[i][7]=""+rs.getDouble("total");
i+=1;
}
closeAll();
}catch(SQLException e){
}
}
public void ReportSum1(String st){
try{
getStmt();
String sqlt1="select sum(num) as b1,sum(total) as a1 from report_table1 where no1='"+st+"'";
rs=stmt.executeQuery(sqlt1);
if(rs.next()){
sut1=rs.getDouble("b1");
sut2=rs.getDouble("a1");
}
sut1=Math.round(sut1*10000);
sut1=sut1/10000;
sut2=Math.round(sut2*100);
sut2=sut2/100;

closeAll();
}catch(SQLException e){
}
}
public void Reportfield2(String st){
try{
getStmt();
String sql21="select * from report_table2 where no1='"+st+"' order by id";
rs=stmt.executeQuery(sql21);
ku1=0;
while(rs.next()){
ku1+=1;
}
JAVANND 2007-05-31
  • 打赏
  • 举报
回复
报表工具要自己去通过代码建立 先用代码比较方便
eg:package base;
import javax.swing.*;
import java.awt.*;
import java.awt.print.*;
import java.util.*;
import java.sql.*;
import ConnectionPool.*;
/**
* <p>Title: 应用程式</p> 收货报告整体内容 pane
* <p>Description: 应用程式开发</p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class ReportPrintPane extends JPanel {
protected JDCConnection con=null;
protected ResultSet rs = null;
protected Statement stmt = null;
protected PreparedStatement pstmt = null;
private boolean isTransaction = false;
String trn="";
final static Color fg = Color.black;
BarCode1 barcode=new BarCode1();
//创建字体
Font font16 = new Font("宋体", Font.BOLD, 16);
Font font11 = new Font("宋体", Font.PLAIN, 11);
String str1="";
String str2="";
String str3="";
Font font8=new Font("宋体",Font.PLAIN,8);
Font font81=new Font("宋体",Font.BOLD,8);
//是否第1页变量
static boolean isFirstPage = true;
//创建销售单数组
String[] saleLedger=new String[24];
//创建销售单明细账数组
int ku=0;
int ku1=0;
int ku2=0;
String[][] saleSubLedger ;
String[][] saleSubLedger1;
String[][] saleSubLedger2;
//创建页码变量
static int printPage = 0;
//页面左边的空白
int pageLeftMargin = 30;
//与左边的距离
int x = 0;
//与项部的距离
int y = 0;
//行宽
int lineHeight = 18;
//行间距
int lineDistant = 18;
//表格的行高
int tableLineHeight = 20;
//表格的总高度
int tableHeight = 0;
int tabHeight=6;
//定义纵坐标的总数,用来求出有多少页及页码的处理
int sumHeight=0; //除最上面显示的内容外的总高度
int pageCount=0; //总页数
int page1Height=0; //实际资料是否显示完了,如果没有则保存显示的记录数
int page2Height=0; //皮重说明显示是否完成,如果没有则保存显示具体的记录数
int page3Height=0;
boolean tf1=true; //实际收货中的合计是否显示
boolean tf2=true; //皮重说明是否显示
boolean tf3=true; //皮重编号是否显示
boolean tf4=true; //欠重是否显示
boolean tf5=true;//货不对板是否显示
boolean tf6=true; //报告示人
boolean t1=true;
boolean t2=true;
int tt1=0;
int tt2=0;
int tt3=0;
int tt4=0;
int tt5=0;
int tt6=0;
int page1=0;
String saleLedger0="";
String saleLedger1="";
String saleLedger2="";
String saleLedger3="";
String saleLedger4="";
String saleLedger5="";
String saleLedger6="";
String saleLedger7="";
String saleLedger8="";
String saleLedger9="";
String saleLedger10="";
String saleLedger11="";
String saleLedger12="";
//创建完成状态数组
String[] onProcesses = {"进行", "撤消", "完成"};
double sut1=0;
double sut2=0;
double sut3=0;
double sut4=0;
double su1=0;
double su2=0;
double su3=0;
double su4=0;
int sumtotal=0;
int kkk=0;
//重新绘画
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
//设置画笔颜色
g2.setPaint(fg);
drawPages(g2);
}
public ReportPrintPane() {
this.setBackground(Color.white);
}
public ReportPrintPane(String str){
// JOptionPane.showMessageDialog(null,"saleorderprintpane str="+ str );
if(str.equals("")){
JOptionPane.showMessageDialog(null,"str不能为空");
}else{
Reportfield(str);
Reportfield1(str);
Reportfield2(str);
Reportfield3(str);
ReportDet1(str);
ReportDet2(str);
ReportDet3(str);
ReportSum1(str);
ReportSum2(str);
ReportSum3(str);
pagesum(); //求出总页数
}
this.setBackground(Color.white);
}
public void pagesum(){
sumHeight=0;
dalilei 2007-01-20
  • 打赏
  • 举报
回复
关注,看到网上有for jb9的水晶报表。
但还不知道怎么用的。
我是从vb到vs.net都用的水晶报表。
lixiaoxue85 2007-01-12
  • 打赏
  • 举报
回复
不明白~~JBUILDER对这个报表有配置支持吗?~~还是用写代码的方式?

50,530

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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