「java怎么写联表统计」java统计报表怎么做的
今天给各位分享java怎么写联表统计的知识,其中也会对java统计报表怎么做的进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
- 1、java 实现报表统计
- 2、Java如何进行数据库里的数据统计
- 3、java web 多表联合查询怎么做
- 4、用java统计数据库的数据
- 5、java写一个多线程程序,计算各种统计值的数字列表。
- 6、如何使用java做统计图表
java 实现报表统计
java本身没有操作excel的工具,需要第三方的jar包,用jxl就可以,代码入下。
jxl你上百度搜索后下载就可以,简单易用,不懂追问。
public boolean exportExcel(HttpServletResponse response,Listcityinfo list)
{
try
{
OutputStream os = response.getOutputStream();// 取得输出流
response.reset();// 清空输出流
response.setHeader("Content-disposition", "attachment; filename=fine.xls");// 设定输出文件头
response.setContentType("application/msexcel");// 定义输出类型
WritableWorkbook wbook = Workbook.createWorkbook(os); // 建立excel文件
String tmptitle = "标题"; // 标题
WritableSheet wsheet = wbook.createSheet("详细信息表", 0); // sheet名称
WritableSheet wsheet = wbook.createSheet("性别统计表", 1); // sheet名称
WritableSheet wsheet = wbook.createSheet("证件类型统计表", 2); // sheet名称
// 设置excel标题
WritableFont wfont = new WritableFont(WritableFont.ARIAL, 16,WritableFont.BOLD,
false,UnderlineStyle.NO_UNDERLINE,Colour.BLACK);
WritableCellFormat wcfFC = new WritableCellFormat(wfont);
wcfFC.setBackground(Colour.AQUA);
wsheet.addCell(new Label(1, 0, tmptitle, wcfFC));
wfont = new jxl.write.WritableFont(WritableFont.ARIAL, 14,WritableFont.BOLD,
false, UnderlineStyle.NO_UNDERLINE,Colour.BLACK);
wcfFC = new WritableCellFormat(wfont);
// 开始生成主体内容
wsheet.addCell(new Label(0, 2, "具体内容"));
for(int i=0;ilist.size();i++) br=""{
wsheet.addCell(new Label(0, i+3, "");
wsheet.addCell(new Label(1, i+3,"");
}
// 主体内容生成结束
wbook.write(); // 写入文件
wbook.close();
os.close(); // 关闭流
return true;
}
catch(Exception ex)
{
ex.printStackTrace();
return false;
}
}
Java如何进行数据库里的数据统计
你这个跟java没什么关系,数据库自己就能实现。
T-SQL这样写就可以了
select * into table2 from table1
where (time3:00 and time5:00) --这句是伪代码,你把条件改对
如果要统计数据条数,另写一条sql查。
如果table2已经建好,请先删除。
-------------------------------------------------------
这还不简单啊,把上面的内容组合一下。
select count(*) as count_num from table1 where (你的条件)
--这句得到数据条数了。
再加上这句
select no,time from table1 where (你的条件)
--这句得到所有符合条件的数据。
插入也可以用子查询
--假设table2的id是自增的
insert into table2(no,time) values(
select no,time from table1 where(你的条件)
)
你在java里通过这些查询已经得到你要的数据了,再处理下就行了。
也可以把所有的查询都变成子查询然后放到一个SQL语句里面,不过好象没必要。
java web 多表联合查询怎么做
hql联合查询我没做过,我给你说下用sql语句的查询方式
前台把查询的参数统统传到action
action调用service,把参数传过来
service调用dao,参数传给 dao
在dao里面,用session.createSQLQuery("查询语句,查")
sql语句,给你个小示例:
select lvl1_Name,lvl2_Name ,lvl0_Name from 主表 left outer join 从表 on 主从表关联的等式
不管从多少表, left outer join 表名 on 两个表关联的等式 ....就可以查出来,
注意哦,有的表字段相同,记得要取别名哦
用java统计数据库的数据
private Connection conn=null;
private PreparedStatement ps=null;
private String DRIVER="com.microsoft.sqlserver.jdbc.SQLServerDriver";
private String STRCONN="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=merchandise";
private String USER="sa";
private String PASS="sasa";
/**
* 创建一个连接方法
*/
public Connection createConnection(){
try {
Class.forName(DRIVER);
conn=DriverManager.getConnection(STRCONN,USER,PASS);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
}
上面是连接 sql server 2005的方法 下面是要查的用法
总数:select count(*)from
表名男生人数:select count(*)from 表名 where
性别那一列的名字='男'女生的把上面改一下就行了
java写一个多线程程序,计算各种统计值的数字列表。
package com.accp.wangyou;
import java.util.Arrays;
public class test {
final int[] arr = { 90, 81, 78, 95, 79, 72, 85 };
public static void main(String[] args) {
new Thread(new test().new runnable1()).start();
new Thread(new test().new runnable2()).start();
new Thread(new test().new runnable3()).start();
}
class runnable1 implements Runnable {
public void run() {
int avg = 0;
for (int i = 0; i arr.length; i++) {
avg += arr[i];
}
System.out.println("平均值为:" + avg / arr.length);
}
}
class runnable2 implements Runnable {
public void run() {
Arrays.sort(arr);
System.out.println("最大值:" + arr[arr.length - 1]);
}
}
class runnable3 implements Runnable {
public void run() {
Arrays.sort(arr);
System.out.println("最小值:" + arr[0]);
}
}
}
如何使用java做统计图表
//参考地址去网站下js控件,下面是饼图的代码,下图是我的代码效果
function query1(housetype,redStatisticsList,text0,cashingSum,tranferSum){
!--红包发放数据--
var myrodiusred = echarts.init(document.getElementById('mainrodius'));//ID
var redHousehold = housetype;
var redMoney = redStatisticsList;
var allMoney = 0;//总金额
$.each(redStatisticsList,function(index,item){
allMoney =allMoney+ Number(item.value);
})
optionTwo = {
title : {
text: text0,
subtext: "总金额:"+allMoney+"\n\n提现总额:"+cashingSum+"\n\n到账总额:"+tranferSum,
x:'center'
},
tooltip : {
trigger: 'item',
formatter: "{a} br/{b} ({d}%)"
},
legend: {
orient: 'vertical',
left: 'left',
data: housetype
},
series : [
{
type: 'pie',
radius : '55%',
center: ['50%', '60%'],
data:redMoney,
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};
myrodiusred.setOption(optionTwo);
}
java怎么写联表统计的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java统计报表怎么做的、java怎么写联表统计的信息别忘了在本站进行查找喔。
发布于:2022-11-22,除非注明,否则均为
原创文章,转载请注明出处。