/**
* 导出清单 eb中 firstRow(EntityBean) 列表第一行数据,键值对(不包含序号)例:("name","姓名")
* data(EntityBean[]) 列表数据
*
* @author zhaojq
*/
public PR exportData(EntityBean eb)
{
if (eb == null)
{
return new PR(0, "参数为空", null);
}
try
{
// 创建表格文件
String rootpath = NameedPathUtil.getDefaultSavePath();
String filepath = "/LSIP/excel/";
File f = new File(rootpath + filepath);// 创建文件夹路径
// 如果文件夹不存在则创建
if (!f.exists() && !f.isDirectory())
{
f.mkdirs();
}
String filename = System.currentTimeMillis() + ".xls";
File file = new File(f, filename);
if (!file.exists())
{
file.createNewFile();
}
EntityBean firstRow = eb.getBean("firstRow");
EntityBean[] data = eb.getBeans("data");
// 创建工作薄
WritableWorkbook workbook = Workbook.createWorkbook(file);
// 创建新的一页
WritableSheet sheet = workbook.createSheet("第1页", 0);
// Label(列,行,数据) // 第一行
String[] keys = firstRow.getBeanFieldNames();// 获取表头key
for (int i = 0; i < keys.length; i++)
{
Label firstrow = new Label(i, 0, firstRow.getString(keys[i]));
sheet.addCell(firstrow);
} // 创建数据行
for (int i = 0; i < data.length; i++)
{
for (int j = 0; j < keys.length; j++)
{
Label datarow = new Label(j, 1 + i, data[i].getString(keys[j]));
sheet.addCell(datarow);
}
}
workbook.write();
workbook.close();
String contex = LSIPConfigUtil.getDownloadConfig();
return new PR(1, "", String.format("%sLEAP/Download/default%s%s", contex, filepath, filename));
}
catch (Exception e)
{
Global.getInstance().LogError(e);
return new PR(0, e.toString(), null);
}
}

  

/**
* 考试清单导出
*/
public PR exportExamQD(SearchParameters spar)
{
try
{
EntityBean par = new EntityBean();
spar.setOrder("seatno");
spar.setPageSize(10000);
EntityBean[] list = examsearch4eb(spar); if(StringUtil.IsNullOrEmpty(list))return new PR(1,"查询结果为空",null);
//第一行数据
EntityBean firstBean = new EntityBean();
firstBean.set("areaname", "地区");
firstBean.set("examroomid", "考试中心");
firstBean.set("examsubject", "考试科目");
firstBean.set("examtime", "考试时间");
firstBean.set("cardno", "证件号码");
firstBean.set("personname", "姓名");
firstBean.set("mobile", "手机号");
firstBean.set("examstate", "考试报名状态");
firstBean.set("examscore", "成绩");
firstBean.set("seatno", "座位号");
firstBean.set("address", "通讯地址");
for(int i = 0;i < list.length;i++)
{
EntityBean _data = list[i];
String areaname = zonepro.getInstance().getAreaName(_data.getString("areaid"));
_data.set("areaname", areaname); if(_data.getString("examroomid") != null)
{
leapcodevalue _examroomid= CodeTypeCache.getInstance().getCodeValue("LSIP_examroom",_data.getString("examroomid"));
if(_examroomid != null)
_data.set("examroomid", _examroomid.getcodevalue());
}
if(_data.getString("examsubject") != null)
{
leapcodevalue _examsubject= CodeTypeCache.getInstance().getCodeValue("LSIP_examsubject",_data.getString("examsubject"));
if(_examsubject != null)
_data.set("examsubject", _examsubject.getcodevalue());
}
if(_data.getString("examtype") != null)
{
leapcodevalue _examtype= CodeTypeCache.getInstance().getCodeValue("LSIP_examtype",_data.getString("examtype"));
if(_examtype != null)
_data.set("examtype", _examtype.getcodevalue());
}
if(_data.getString("examstate") != null)
{
leapcodevalue _examstate= CodeTypeCache.getInstance().getCodeValue("LSIP_examstate",_data.getString("examstate"));
if(_examstate != null)
_data.set("examstate", _examstate.getcodevalue());
}
if(_data.getString("examtime") != null)
{
_data.set("examtime", _data.getString("examtime").substring(0, 16));
}
}
par.set("firstRow", firstBean);
par.set("data", list);
return new BaseDataService().exportData(par);
}
catch (Exception e)
{
Global.getInstance().LogError(e);
return new PR(0,e.getMessage(),null);
}
}

  

最新文章

  1. Delphi_06_Delphi_Object_Pascal_基本语法_04
  2. C/C++ 静态链接库(.a) 与 动态链接库(.so)
  3. Docker-3:Data Volume
  4. java的debug和release编译方式
  5. Excel保护工作表
  6. Navicat 回复 psc 文件 Mysql
  7. js高级程序设计(四)变量、作用域和内存问题
  8. Educational Codeforces Round 15 B
  9. Css中光标,DHTML,缩放的使用
  10. [JS代码]如何判断ipad或者iphone是否为横屏或者竖屏 - portrait或者landscape
  11. mysql中常用的语句整理
  12. php入门微理解
  13. 【Espruino】NO.15 nRF24L01+无线收发器
  14. python webdriver环境搭建
  15. (三十八)从私人通讯录引出的细节II -数据逆传 -tableView点击 -自定义分割线
  16. Asp.Net WebApi 使用OWIN架构后,出现 “没有 OWIN 身份验证管理器与此请求相关联(No OWIN authentication manager is associated with the request)” 异常的解决办法
  17. [HNOI2007]梦幻岛宝珠
  18. 修改Mysql字符集
  19. [SHOI2013]发牌 解题报告
  20. npm的.npmrc文件在哪里?缓存及全局包文件在什么位置?

热门文章

  1. 读取EXCEL数据到内存DataTable
  2. 09 Request/Response
  3. 分布式缓存技术redis学习系列(五)——redis实战(redis与spring整合,分布式锁实现)
  4. AMR 转mp3 失败
  5. [转]netty对http协议解析原理
  6. CSS的Hack技术
  7. 01@MySQL_Course_LabVIEW+MySQL程序开发
  8. JSF 与 HTML 标签的联系
  9. Django入门2
  10. 保护眼睛(ubuntu 和 chrome)