chenjiahe
2023-05-31 7f9b53d982c0210ffc25db3a639bd858fc5db79b
数据库公用方法添加
1个文件已修改
47 ■■■■■ 已修改文件
src/main/java/com/hx/util/ExcelUtil.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/hx/util/ExcelUtil.java
@@ -57,10 +57,11 @@
        // 在索引0的位置创建行(最顶端的行)
        HSSFRow row = sheet.createRow(0);
        // ===============================================================
        for (int i = 0; i < headList.length; i++) {
        HSSFCell cell;
        for (int i = 0; i < headList.length; i++) {
            // 在索引0的位置创建单元格(左上端)
            HSSFCell cell = row.createCell(i);
            cell = row.createCell(i);
            // 定义单元格为字符串类型
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            // 在单元格中输入一些内容
@@ -68,14 +69,16 @@
        }
        // ===============================================================
        if (dataList != null) {
            HSSFRow row_value;
            Map<String, Object> dataMap;
            for (int n = 0; n < dataList.size(); n++) {
                // 在索引1的位置创建行
                HSSFRow row_value = sheet.createRow(n + 1);
                Map<String, Object> dataMap = dataList.get(n);
                row_value = sheet.createRow(n + 1);
                dataMap = dataList.get(n);
                // ===============================================================
                for (int i = 0; i < fieldList.length; i++) {
                    // 在索引0的位置创建单元格(左上端)
                    HSSFCell cell = row_value.createCell(i);
                    cell = row_value.createCell(i);
                    // 定义单元格为字符串类型
                    cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                    // 在单元格中输入一些内容
@@ -125,10 +128,10 @@
            // 在索引0的位置创建行(最顶端的行)
            HSSFRow row = sheet.createRow(0);
            // ===============================================================
            HSSFCell cell;
            for (int i = 0; i < headList.length; i++) {
                // 在索引0的位置创建单元格(左上端)
                HSSFCell cell = row.createCell(i);
                cell = row.createCell(i);
                // 定义单元格为字符串类型
                cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                // 在单元格中输入一些内容
@@ -136,14 +139,16 @@
            }
            // ===============================================================
            if (dataList != null) {
                HSSFRow row_value;
                Map<String, Object> dataMap;
                for (int n = 0; n < dataList.size(); n++) {
                    // 在索引1的位置创建行
                    HSSFRow row_value = sheet.createRow(n + 1);
                    Map<String, Object> dataMap = dataList.get(n);
                    row_value = sheet.createRow(n + 1);
                    dataMap = dataList.get(n);
                    // ===============================================================
                    for (int i = 0; i < fieldList.length; i++) {
                        // 在索引0的位置创建单元格(左上端)
                        HSSFCell cell = row_value.createCell(i);
                        cell = row_value.createCell(i);
                        // 定义单元格为字符串类型
                        cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                        // 在单元格中输入一些内容
@@ -204,12 +209,13 @@
            // 在索引0的位置创建行(最顶端的行)
            HSSFRow row = sheet.createRow(0);
            // ===============================================================
            HSSFCell cell;
            for (int i = 0; i < headList.length; i++) {
                //高度
                row.setHeight(height.shortValue());
                sheet.setColumnWidth(i,width);
                // 在索引0的位置创建单元格(左上端)
                HSSFCell cell = row.createCell(i);
                cell = row.createCell(i);
                // 定义单元格为字符串类型
                cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                // 在单元格中输入一些内容
@@ -218,16 +224,18 @@
            }
            // ===============================================================
            if (dataList != null) {
                HSSFRow row_value;
                Map<String, Object> dataMap;
                for (int n = 0; n < dataList.size(); n++) {
                    // 在索引1的位置创建行
                    HSSFRow row_value = sheet.createRow(n + 1);
                    row_value = sheet.createRow(n + 1);
                    row_value.setHeight(height.shortValue());
                    Map<String, Object> dataMap = dataList.get(n);
                    dataMap = dataList.get(n);
                    // ===============================================================
                    for (int i = 0; i < fieldList.length; i++) {
                        // 在索引0的位置创建单元格(左上端)
                        sheet.setColumnWidth(i,width);
                        HSSFCell cell = row_value.createCell(i);
                        cell = row_value.createCell(i);
                        // 定义单元格为字符串类型
                        cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                        // 在单元格中输入一些内容
@@ -292,12 +300,13 @@
            // 在索引0的位置创建行(最顶端的行)
            XSSFRow row = sheet.createRow(0);
            // ===============================================================
            XSSFCell cell;
            for (int i = 0; i < headList.length; i++) {
                //高度
                row.setHeight(height.shortValue());
                sheet.setColumnWidth(i,width);
                // 在索引0的位置创建单元格(左上端)
                XSSFCell cell = row.createCell(i);
                cell = row.createCell(i);
                // 定义单元格为字符串类型
                cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                // 在单元格中输入一些内容
@@ -306,16 +315,18 @@
            }
            // ===============================================================
            if (dataList != null) {
                XSSFRow row_value;
                Map<String, Object> dataMap;
                for (int n = 0; n < dataList.size(); n++) {
                    // 在索引1的位置创建行
                    XSSFRow row_value = sheet.createRow(n + 1);
                    row_value = sheet.createRow(n + 1);
                    row_value.setHeight(height.shortValue());
                    Map<String, Object> dataMap = dataList.get(n);
                    dataMap = dataList.get(n);
                    // ===============================================================
                    for (int i = 0; i < fieldList.length; i++) {
                        // 在索引0的位置创建单元格(左上端)
                        sheet.setColumnWidth(i,width);
                        XSSFCell cell = row_value.createCell(i);
                        cell = row_value.createCell(i);
                        // 定义单元格为字符串类型
                        cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                        // 在单元格中输入一些内容