|
|
|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.jfinal.kit.Kv;
|
|
|
|
|
import com.jfinal.kit.PathKit;
|
|
|
|
|
import com.jfinal.kit.PropKit;
|
|
|
|
|
import com.jfinal.kit.StrKit;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Page;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
import com.jfinal.upload.UploadFile;
|
|
|
|
@ -53,7 +54,7 @@ public class ExcelCommonUtil {
|
|
|
|
|
export(page, jo, fileName, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void export(Page<?> page, JSONObject jo, String fileName, List<Integer> hiddenColumns) {
|
|
|
|
|
public static void export(Page<?> page, JSONObject jo, String fileName, List<Integer> hiddenColumns, String column_name) {
|
|
|
|
|
//标题
|
|
|
|
|
String title = jo.getString("title");
|
|
|
|
|
|
|
|
|
@ -71,7 +72,8 @@ public class ExcelCommonUtil {
|
|
|
|
|
JSONArray colInfo = jo.getJSONArray("colInfo");
|
|
|
|
|
if (showNumber != null) {
|
|
|
|
|
JSONObject addjo = new JSONObject();
|
|
|
|
|
addjo.put("show_column_name", "序号");
|
|
|
|
|
if (StrKit.isBlank(column_name)) addjo.put("show_column_name", "序号");
|
|
|
|
|
else addjo.put("show_column_name", column_name);
|
|
|
|
|
addjo.put("list_column_name", "Number");
|
|
|
|
|
addjo.put("width", 20);
|
|
|
|
|
colInfo.add(0, addjo);
|
|
|
|
@ -214,6 +216,11 @@ public class ExcelCommonUtil {
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void export(Page<?> page, JSONObject jo, String fileName, List<Integer> hiddenColumns) {
|
|
|
|
|
export(page, jo, fileName, hiddenColumns, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -849,7 +856,7 @@ public class ExcelCommonUtil {
|
|
|
|
|
* @param fileLists excel文件路径
|
|
|
|
|
* @param fileName 目标文件名称
|
|
|
|
|
*/
|
|
|
|
|
public static void mergeExcel(List<String> fileLists, String fileName,int whiceRowGetColWidth) {
|
|
|
|
|
public static void mergeExcel(List<String> fileLists, String fileName, int whiceRowGetColWidth) {
|
|
|
|
|
// 创建新的excel工作簿
|
|
|
|
|
XSSFWorkbook book = new XSSFWorkbook();
|
|
|
|
|
// 遍历需要合并的excel文件
|
|
|
|
@ -863,7 +870,7 @@ public class ExcelCommonUtil {
|
|
|
|
|
XSSFSheet tmpSheet = tmpWorkBook.getSheetAt(i);
|
|
|
|
|
XSSFSheet newExcelSheet = book.createSheet(tmpSheet.getSheetName());
|
|
|
|
|
// 复制sheet内容
|
|
|
|
|
copyExcelSheet(book, tmpSheet, newExcelSheet,whiceRowGetColWidth);
|
|
|
|
|
copyExcelSheet(book, tmpSheet, newExcelSheet, whiceRowGetColWidth);
|
|
|
|
|
}
|
|
|
|
|
// 关闭tmpWorkBook工作簿
|
|
|
|
|
tmpWorkBook.close();
|
|
|
|
|