| | |
| | | List<String> cellList = dataList.get(y); |
| | | Row row = sheet.createRow(y); |
| | | for (int x = 0; x < cellList.size(); x++) { |
| | | row.createCell(x).setCellValue(cellList.get(x)); |
| | | String header = y > 0 && !dataList.isEmpty() && x < dataList.get(0).size() ? dataList.get(0).get(x) : null; |
| | | row.createCell(x).setCellValue(maskSensitiveValue(header, cellList.get(x))); |
| | | } |
| | | } |
| | | |
| | |
| | | outStream.close(); |
| | | } |
| | | |
| | | private static String maskSensitiveValue(String columnName, String value) { |
| | | if (value == null || columnName == null) return value; |
| | | String column = columnName.toLowerCase(); |
| | | if (column.contains("身份证") || column.contains("idcard") || column.contains("identity")) return value.length() <= 10 ? stars(value.length()) : value.substring(0, 6) + stars(value.length() - 10) + value.substring(value.length() - 4); |
| | | if (column.contains("电话") || column.contains("手机") || column.contains("phone") || column.contains("mobile")) return value.length() <= 7 ? stars(value.length()) : value.substring(0, 3) + "****" + value.substring(7); |
| | | return value; |
| | | } |
| | | private static String stars(int count) { StringBuilder result = new StringBuilder(); for (int i = 0; i < count; i++) result.append('*'); return result.toString(); } |
| | | |
| | | /** |
| | | * 复杂杂模板excel导出(合并单元格、设置表格样式等) |
| | | * @param request |