package com.util.export.impl;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jxl.Workbook;
import jxl.format.UnderlineStyle;
import jxl.write.Label;
import jxl.write.Number;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import com.scholarship.module.account.Account;
import com.scholarship.module.college.College;
import com.scholarship.module.conf.AppConfig;
import com.scholarship.module.datas.Datas;
import com.scholarship.module.export.ExportCustom;
import com.scholarship.module.grade.Grade;
import com.scholarship.module.scholarship.Scholarship;
import com.scholarship.service.account.AccountService;
import com.scholarship.service.apply.ApplyService;
import com.scholarship.service.college.CollegeService;
import com.scholarship.service.datas.DatasService;
import com.scholarship.service.grade.GradeService;
import com.scholarship.service.scholarship.ScholarshipService;
import com.util.StringUtil;
public class ExportTypeCustom extends Export {
// ExportCustom es = new ExportCustom();
/***
* 导出自定义所有数据
*/
public ExportTypeCustom(Account account, AccountService accountService,
ApplyService applyService, CollegeService collegeService,
GradeService gradeService, DatasService datasService,
ScholarshipService scholarshipService) {
super(account, accountService, applyService, collegeService, gradeService, datasService,
scholarshipService);
// TODO Auto-generated constructor stub
}
/***
* 导出自定义所有数据
*/
@SuppressWarnings({ "resource", "finally" })
@Override
public InputStream export(String year) {
// TODO Auto-generated method stub
Map<String,String> map = new HashMap<String,String>();
if(account.getRole().getId()!=1){
map.put("roleId", String.valueOf(account.getRole().getId()));//当前账户角色可以看到的审批
}
map.put("year", year);//年份
map.put("status", "2");//审批已通过
int i =1;
List<String> l = new ArrayList<>();
while(null!=scholarshipServie.queryById(i)){
l.add(String.valueOf(i++));
}
// String ids = es.getIds();
// String ids ="1,2,3,4,5,6,7,8,9,10,11"
// String[] l;
// if(StringUtil.isNotBlank(ids)){
// l = ids.split(",");
// }
String filePath = AppConfig.ctx+"csvTemplate\\自定义表格"+year+".xls";
InputStream input = null;
try {
OutputStream os = new FileOutputStream(filePath);
WritableWorkbook wwb = Workbook.createWorkbook(os);
if(l!=null){
System.out.println("==============Start ExportCustomerTable");
for(String id : l){
Scholarship s = scholarshipServie.queryById(Integer.parseInt(id));
String tip = s.getCategory()+s.getLevel();
map.put("scholarshipId", id);
List<Account> accountList = applyService.queryAccountList(map);
System.out.println("导出:"+s.getCategory()+s.getLevel()+" 人数:"+accountList.size());
WritableSheet sheet = wwb.createSheet(tip, 0);
this.werite(accountList, sheet, year, tip,s);
}
System.out.println("==============End ExportCustomerTable");
}
wwb.write();
wwb.close();
input = new FileInputStream(filePath);
} catch (IOException | WriteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("Export Table has fail--");
}finally{
return input;
}
}
private int werite(List<Account> accountList,WritableSheet sheet, String year, String category, Scholarship s) throws WriteException{
String[] title_student = {"序号","姓名","学号","密码","性别","QQ","电话","电子邮件"};
String[] title_class = {"学院","班级","专业","学历","入学年份","年级","学年"};
String[] title_datas = {"出生年月","身份证号","银行卡号","民族","东部","中部","西部","家庭住址","住址简写","离县城远近","月生活费","生源地贷款","爷爷","爷爷收入","爷爷健康","奶奶","奶奶收入","奶奶健康","父亲","父亲收入","父亲职业","父亲身体","母亲","母亲收入","母亲职业","母亲身体","兄弟姐妹","家庭收入","主要支出","结余","主要困难原因","变故","成绩排名","素质排名"};
String[] title_scholarship = {"奖金种类","奖金等级","奖金金额"};
WritableCellFormat cellFormat = new WritableCellFormat();
Label label=null;
Number number=null;
int row = 4;
int column = 0;
for(;column<title_student.length+title_class.length+title_datas.length+title_scholarship.length;column++){
sheet.setColumnView(column, 20); // 设置列的宽度
}
WritableFont wf_table = new WritableFont(WritableFont.ARIAL, 18,
WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.BLACK);// 定义格式 字体 下划线 斜体 粗体 颜色
WritableFont wf_title = new WritableFont(WritableFont.ARIAL, 13,
WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.BLACK);
WritableFont wf_content = new WritableFont(WritableFont.ARIAL, 11,
WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.BLACK);
label = new Label(0, 1, "黄冈师范学院自定义导出表("+year+"年"+category+")");
cellFormat.setFont(wf_table);
cellFormat.setAlignment(jxl.format.Alignment.CENTRE);//设置对齐方式
cellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN,jxl.format.Colour.BLACK); //设置边框
label.setCellFormat(cellFormat);
sheet.addCell(label);
sheet.mergeCells(0, 1, 7, 1);//合并大标题
column = 0;
//表头1
for (int i = 0; i < title_student.length; i++,column++) {
label = new Label(column,row,title_student[i]);
cellFormat = new WritableCellFormat();
cellFormat.setFont(wf_title);
cellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN,jxl.format.Colour.BLACK); //设置边框
// cellFormat.setWrap(true);//自动换行
label.setCellFormat(cellFormat);
sheet.addCell(label);
}
//表头2
for (int i = 0; i < title_class.length; i++,column++) {
label = new Label(column,row,title_class[i]);
cellFormat = new WritableCellFormat();
cellFormat.setFont(wf_title);
cellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN,jxl.format.Colour.BLACK); //设置边框
// cellFormat.setWrap(true);//自动换行
label.setCellFormat(cellFormat);
sheet.addCell(label);
}
//表头3
for (int i = 0; i < title_datas.length; i++,column++) {
label = new Label(column,row,title_datas[i]);
cellFormat = new WritableCellFormat();
cellFormat.setFont(wf_title);
cellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN,jxl.format.Colour.BLACK); //设置边框
// cellFormat.setWrap(true);//自动换行
label.setCellFormat(cellFormat);
sheet.addCell(label);
}
//表头4
for (int i = 0; i < title_scholarship.length; i++,column++) {
label = new Label(column,row,title_scholarship[i]);
cellFormat = new WritableCellFormat();
cellFormat.setFont(wf_title);
cellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN,jxl.format.Colour.BLACK); //设置边框
// cellFormat.setWrap(true);//自动换行
label.setCellFormat(cellFormat);
sheet.addCell(label);
}
row++;
for(Account a : accountList){
column = 0;
// Syst
AI拉呱
- 粉丝: 2908
- 资源: 5549
最新资源
- 基于Matlab与Simulink的六自由度水下机器人滑模控制运动模型:S-function与Matlab function互换应用,实现无差度轨迹跟踪效果,注释与文档详尽解析,基于Matlab与si
- C#与Halcon运动控制视觉框架源码分享:可连线式操作,自由添加运动控制,开源二次开发无界限,C#联合Halcon运动控制源代码,视觉框架源码, 连线式,halcon程序,运动控制可以自己随意添加
- COMSOL MXene超材料吸收器的性能研究:高效能量转换与吸收机制探索,comsol MXene超材料吸收器 ,核心关键词:comsol; MXene超材料; 吸收器; 电磁波吸收 ,"Coms
- 2024工业场景人形机器人应用前景研报 1. 人形机器人产业发展概况; 2. 工业场景人形机器人应用情况分析; 3. 工业市场人形机器人竞争格局分析; 4. 工业市场人形机器人发展趋势分析
- IBMHeapAnalyzer
- 基于Simulink的船用四缸柴油机动态模型研究,包括PID控制及部件建模说明,【船用柴油机Simulink动态模型】 CI发动机 1、四缸,额定功率550kw,转速1000rpm 2、带PID控制
- 基于COMSOL的三相变压器仿真:振动噪声、温度场及多物理场耦合分析,COMSOL三相变压器仿真振动噪声温度 变压器磁致伸缩振动噪声 温度 应力 形变 温度多场耦合计算 ,船用柴油机; Simulin
- 2024创新药及供应链年度创新白皮书 2024 的中国生物医药行业已经进入触底反弹的恢复期 尽管资本仍然审慎、IPO 依然收紧, 但暖阳已经穿越寒冬,播洒暖意!
- COMSOL模拟土石混合体孔隙渗流中的细颗粒迁移运动:多场多相介质耦合分析,COMSOL孔隙渗流下的细颗粒迁移运动 对土石混合体进行了数值仿真,考虑了土石混合体孔隙变化,细颗粒侵蚀,骨架结构变形,此
- Matlab Simulink下的风储调频系统:四机两区联合仿真,快速响应与频率优化控制,附虚拟惯性与下垂控制特性,伯德图与根轨迹分析支持下的风电渗透率研究,matlab simulink 风储调频
- 递归最小二乘法在车辆前后轮胎侧偏刚度估算中的应用:实车实验验证与算法参数需求分析,基于递归最小二乘法估计的车辆前后轮胎的侧偏刚度,如仿真结果图可知,在恒定转角变化速度下,能够很好的估算出前后轮胎的平均
- Html5 Canvas绘制圆形仪表盘动画特效源码.zip
- 基于TSMC28工艺库的10bit 100MSAR ADC高性能转换技术,10bit 100M sar adc 采用的是tsmc28工艺库 ,核心关键词:10bit; 100M sar adc; t
- 四轮转向汽车Carsim-Simulink联合仿真滑模控制模型详解:包含驾驶员与车辆模型、相关文献及技术文档指南,四轮转向汽车Carsim-simulink联合仿真滑模控制模型(.cpar文件 .s
- 基于Fracman离散裂隙网络建模的水力压裂油气藏数值模拟研究,fracman离散裂隙网络建模 水力压裂 油气藏数值模拟 ,核心关键词:fracman; 离散裂隙网络建模; 水力压裂; 油气藏数值模拟
- 2024算法与AI大模型的用户认知调研报告 2024 年 8 月,我们在全国范围内发放了面向消费者的调查问卷,试图了解目前我国消费者关于 AI 大模型以及算法的认知情况
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈