美文网首页
大数据导出(最高可达2.6624亿)

大数据导出(最高可达2.6624亿)

作者: 天黑了心还亮着 | 来源:发表于2017-11-21 19:35 被阅读0次

[java] view plain copy print?SXSSFWorkbook wb = new SXSSFWorkbook(15);// 构造一个空的工作薄,并指定一个窗口访问 Sheet sh = wb.createSheet(); // 居中 // 宽度设置 sh.setColumnWidth(0, 25 * 256); sh.setColumnWidth(1, 35 * 256); sh.setColumnWidth(2, 20 * 256); sh.setColumnWidth(3, 20 * 256); sh.setColumnWidth(4, 20 * 256); sh.setColumnWidth(5, 20 * 256); sh.setColumnWidth(6, 20 * 256); sh.setColumnWidth(7, 20 * 256); sh.setColumnWidth(8, 20 * 256); sh.setColumnWidth(9, 20 * 256); sh.setColumnWidth(10, 20 * 256); // 高度设置 sh.createRow(0).setHeightInPoints(20); sh.createRow(1).setHeightInPoints(20); sh.createRow(2).setHeightInPoints(20); sh.createRow(3).setHeightInPoints(20); sh.createRow(4).setHeightInPoints(20); sh.createRow(5).setHeightInPoints(20); sh.createRow(6).setHeightInPoints(20); sh.createRow(7).setHeightInPoints(20); sh.createRow(8).setHeightInPoints(20); sh.createRow(9).setHeightInPoints(20); sh.createRow(10).setHeightInPoints(20); Row row = sh.createRow(0); // ---------------------创建列设置列明----------------------------- Cell cel0 = row.createCell(0); cel0.setCellValue("流水号"); Cell cel1 = row.createCell(1); cel1.setCellValue("日期"); Cell cel2 = row.createCell(2); cel2.setCellValue("玩家ID"); Cell cel3 = row.createCell(3); cel3.setCellValue("桌号"); Cell cel4 = row.createCell(4); cel4.setCellValue("游戏"); Cell cel5 = row.createCell(5); cel5.setCellValue("种类"); Cell cel6 = row.createCell(6); cel6.setCellValue("支付渠道"); Cell cel7 = row.createCell(7); cel7.setCellValue("现金"); Cell cel8 = row.createCell(8); cel8.setCellValue("派币"); Cell cel9 = row.createCell(9); cel9.setCellValue("砖石"); Cell cel10 = row.createCell(10); cel10.setCellValue("状态"); // ------------------定义表头---------------------------------------- Listlist = new ArrayList();

int page_size = 10000;// 数据库中存储的数据行数

// 添加条件

String curMerId = session.get("merchantId");

if (vo.typeList != null && vo.typeList.removeAll(Collections.singleton(null))) {

vo.typeList = null;

}

if (vo.merchantId == 0)

vo.merchantId = Long.parseLong(curMerId);

int list_count = Transaction.findList(vo).totalCount;// 数据的总数量

// -----------------判断需要查询的次数----------------------------------------

int export_times = list_count % page_size > 0 ? list_count / page_size

+ 1 : list_count / page_size;

for (int j = 0; j < export_times; j++) {

// 查询所有的数据

vo.pageNo = j + 1;// 单次查询的页码

vo.pageSize = page_size;// 单次查询的总条数

list = Transaction.findListTwo(vo, list_count).items;// 单词查询的数据类容集合

int len = list.size() < page_size ? list.size() : page_size;// 判断查询的数据长度

for (int i = 0; i < len; i++) {

Row row_value = sh.createRow(j * page_size + i + 1);// 代表行

// ---------向每一行中添加列内容--------

Cell cel0_value = row_value.createCell(0);

cel0_value.setCellValue(String.valueOf(list.get(i).id));// 流水号

Cell cel1_value = row_value.createCell(1);

cel1_value.setCellValue(list.get(i).createTime.toString());// 日期

Cell cel2_value = row_value.createCell(2);

cel2_value.setCellValue(list.get(i).playerId);// 玩家ID

Cell cel3_value = row_value.createCell(3);

cel3_value.setCellValue(list.get(i).deskId);// 桌号

Cell cel4_value = row_value.createCell(4);

if (list.get(i).game != null) {

cel4_value.setCellValue(list.get(i).game.name);// 游戏

} else {

cel4_value.setCellValue("空");// 游戏

}

Cell cel5_value = row_value.createCell(5);

cel5_value.setCellValue(list.get(i).type.title);// 种类

Cell cel6_value = row_value.createCell(6);

if (list.get(i).channel == null)

cel6_value.setCellValue("null");// 支付渠道

else

cel6_value.setCellValue(list.get(i).channel.title);// 支付渠道

Cell cel7_value = row_value.createCell(7);

cel7_value.setCellValue(list.get(i).money);// 现金

Cell cel8_value = row_value.createCell(8);

cel8_value.setCellValue(list.get(i).coin);// 派币

Cell cel9_value = row_value.createCell(9);

cel9_value.setCellValue(list.get(i).points);// 砖石

Cell cel10_value = row_value.createCell(10);

if (list.get(i).status != null) {

cel10_value.setCellValue(list.get(i).status.title);// 状态

} else {

cel10_value.setCellValue("null");// 状态

}

}

list.clear();// 清除list

}

response.current().contentType="octets/stream";

String filename = "流水数据-" + new DateTime().now().toString("yyyyMMddHHmmss") + ".xls";

response.current().setHeader("Content-Disposition","attachment;filename="+filename);

ByteArrayOutputStream baout = new ByteArrayOutputStream();

wb.write(baout);

ByteArrayInputStream bais = new ByteArrayInputStream(baout.toByteArray());

byte[] bs = IO.readContent(bais);

response.out.write(bs);

baout.close();

response.out.flush();

response.out.close();

相关文章

  • 大数据导出(最高可达2.6624亿)

    [java] view plain copy print?SXSSFWorkbook wb = new SXSSF...

  • MySQL的数据导入导出

    MySQL数据库的导入导出 导出 导出数据库 导出数据 导出单表数据 导出单表数据结构 操作数据库 导出整个数据库...

  • MySQL导入导出一个、多个、全部数据库,一张、多张表

    导出 导出一个数据库 导出多个数据库 导出全部数据库 导出一张表 导出多张表 导入 导入一个数据库 导入多个数据库...

  • MySQL备份还原

    备份数据库,备份表 导出数据库,表结构+数据 导出数据库,仅表结构。-d 不导出数据只导出结构,--add-dro...

  • Oracle数据库常见操作

    一篇详尽的Oracle常见语句记录~~不断补充 数据导出 导出库 导入库 数据泵导出 数据泵导入 基操 导出数据库...

  • mysqldump备份数据

    标签(空格分隔): mysql 1 导出数据库 1.1 导出所有数据库 1.2 导出单个数据库 1.3 导出...

  • mysql 数据库导入导出

    mysql 数据库导入导出 一般形式: 注意: 一:数据库的导出 导出数据库结构和数据(此时不用加-d),如下导出...

  • PHP导出大量数据到Excel

    导出数据到Excel,想必大家都有所了解,开发过程中也经常会遇到这种需求。假如导出的数据量不大还好说,数据量稍微大...

  • 如何dump数据库中数据

    具体使用如下: 1、按库导出数据 2、按表导出数据 3、按具体条件导出数据

  • pl/sql导出表结构及表数据

    这是只导出表的创建语句 这是导出表的数据 导出大文本类出错未能解决出错,网上教程右键表Object selecti...

网友评论

      本文标题:大数据导出(最高可达2.6624亿)

      本文链接:https://www.haomeiwen.com/subject/hezwvxtx.html