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
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
基于java的奖助学金系统-可执行内含文档代码-可执行内含文档代码.zip (776个子文件)
0001 65KB
0002 67KB
0003 123KB
0004 49KB
0005 120KB
0006 139KB
0007 105KB
0008 140KB
0009 112KB
0010 147KB
0011 135KB
0012 84KB
0013 116KB
0014 128KB
0015 147KB
0016 131KB
0017 136KB
0018 119KB
0019 127KB
0020 130KB
0021 131KB
0022 114KB
0023 104KB
0024 92KB
0025 106KB
0026 124KB
0027 120KB
0028 131KB
0029 125KB
0030 121KB
0031 125KB
0032 120KB
0033 114KB
0034 119KB
0035 108KB
0036 142KB
0037 110KB
0038 140KB
0039 96KB
0040 83KB
0041 135KB
0042 135KB
0043 102KB
0044 139KB
0045 130KB
0046 116KB
0047 131KB
0048 124KB
0049 116KB
0050 118KB
0051 96KB
0052 101KB
0053 95KB
0054 111KB
0055 97KB
0056 116KB
0057 98KB
0058 145KB
0059 128KB
0060 143KB
0061 126KB
0062 115KB
0063 195KB
0064 149KB
0065 94KB
0066 161KB
AccountAction.class 25KB
ApplyAction.class 19KB
DatasAction.class 14KB
GradeAction.class 14KB
RoleAction.class 13KB
StringUtil.class 11KB
Datas.class 11KB
ExportType2.class 10KB
AnalyzerXML.class 10KB
ExportType4.class 9KB
ExportType3.class 9KB
ExportType1.class 9KB
ExportType5.class 9KB
CollegeAction.class 8KB
LoginAction.class 8KB
ApplyServiceImpl.class 7KB
AnalyzerXML.class 7KB
RoleServiceImpl.class 7KB
ConfigAction.class 6KB
AuditServiceImpl.class 6KB
AuditAction.class 6KB
ScholarshipAction.class 6KB
DateUtil.class 6KB
PageListData.class 5KB
GradeServiceImpl.class 5KB
AccountServiceImpl.class 4KB
RoleDaoImpl.class 4KB
GradeDaoImpl.class 4KB
LoginFilter.class 4KB
SelectGradeAction.class 4KB
CollegeServiceImpl.class 4KB
Account.class 4KB
Export.class 4KB
DatasServiceImpl.class 4KB
共 776 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
AI拉呱
- 粉丝: 2861
- 资源: 5511
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- hrnet关键点检测onnx模型
- chromedriver-win64-132.0.6808.0
- chromedriver-win64-132.0.6807.0
- chromedriver-win64-132.0.6806.0
- 带有界面的多线程爬虫软件源码,使用python爬取漫画图片,可采用多线程爬取,可做毕业设计
- chromedriver-win64-132.0.6804.0
- 我电脑的zsh配置,oh my zsh + powerlevel10k + Hack Nerd Font
- pcie xdma xilinx 上位机应用
- chromedriver-win64-132.0.6803.1
- chromedriver-win64-132.0.6803.0
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功