|
|
|
@ -60,7 +60,7 @@ public class GenerateExcel {
|
|
|
|
|
for (int i = 1; i <= columnCount; i++) {
|
|
|
|
|
Cell cell = row.createCell(i - 1);
|
|
|
|
|
Object value = resultSet.getObject(i);
|
|
|
|
|
cell.setCellValue(value.toString());
|
|
|
|
|
if (value != null) cell.setCellValue(value.toString());
|
|
|
|
|
cell.setCellStyle(dataStyle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -108,13 +108,13 @@ public class GenerateExcel {
|
|
|
|
|
List<String> files = getFiles(directoryPath);
|
|
|
|
|
int cnt = 0;//有问题的查询个数
|
|
|
|
|
for (String file : files) {
|
|
|
|
|
if(!file.contains(".sql")) continue;
|
|
|
|
|
if (!file.contains(".sql")) continue;
|
|
|
|
|
String sql = FileUtil.readUtf8String(file);
|
|
|
|
|
try {
|
|
|
|
|
String excelFilePath = file.replace(".sql", ".xlsx");
|
|
|
|
|
ResultSet rs = statement.executeQuery(sql);
|
|
|
|
|
//如果数据集是空的,返回
|
|
|
|
|
if(!rs.isBeforeFirst()) continue;
|
|
|
|
|
if (!rs.isBeforeFirst()) continue;
|
|
|
|
|
//否则导出
|
|
|
|
|
cnt++;
|
|
|
|
|
exportResultSetToExcel(rs, excelFilePath);
|
|
|
|
|