main
黄海 9 months ago
parent 263b423870
commit 7533f53f5b

@ -159,13 +159,14 @@ public class DataEaseController extends Controller {
*/
@Before(GET.class)
@IsLoginInterface({})
@IsNumericInterface({"id"})
public void downSampleExcel(int id) throws IOException {
String identity_idStr = CookieUtil.getValue(getRequest(), "identity_id");
int identity_id = 1;
if (!StrKit.isBlank(identity_idStr)) {
identity_id = Integer.parseInt(identity_idStr);
}
String area_name = "";
String area_name = "云南省";
//获取他是哪个城市的管理员
if (identity_id == 2) {
area_name = "昆明市";
@ -180,7 +181,7 @@ public class DataEaseController extends Controller {
//导出excel
String excelFileName = dm.exportExcel(identity_id, tableName, dataSetName, tempDir, area_name);
//renderFile
renderFile(new File(excelFileName), "【" + area_name + "】" + dataSetName + "." + "xlsx");
renderFile(new File(excelFileName), "【样例:" + area_name + "】" + dataSetName + "." + "xlsx");
}
/**

@ -860,21 +860,17 @@ public class ExcelCommonUtil {
}
}
if (tableData == null || tableData.isEmpty()) {
//throw new IllegalArgumentException("The list of records must not be empty.");
return;
}
// 创建Excel工作簿
Workbook workbook = new XSSFWorkbook();
// 创建一个Excel工作表
Sheet sheet = workbook.createSheet("Sheet1");
if(tableData!=null && !tableData.isEmpty() ){
// 获取第一个Record的元数据以确定列名
Record firstRecord = tableData.getFirst();
String[] headers = firstRecord.getColumnNames();
int columnCount = headers.length;
// 创建Excel工作簿
Workbook workbook = new XSSFWorkbook();
// 创建一个Excel工作表
Sheet sheet = workbook.createSheet("Sheet1");
// 创建标题行
Row titleRow = sheet.createRow(0);
// 设置标题行的样式
@ -931,6 +927,7 @@ public class ExcelCommonUtil {
int newColumnWidth = Math.max(minColumnWidth, columnWidth);
sheet.setColumnWidth(i, newColumnWidth);
}
}
// 将工作簿写入文件
try (FileOutputStream fileOut = new FileOutputStream(filePath)) {

Loading…
Cancel
Save