Skip to content

Commit 97f2c2a

Browse files
Merge pull request #48 from aquality-automation/Bug51-export-creation
Bug\51 export creation
2 parents a296be6 + 47508bc commit 97f2c2a

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# CHANGELOG
22

3+
## 0.3.6 (unreleased)
4+
5+
Features:
6+
7+
Bugfixes:
8+
- Fixed for downloading audits results from Audits Dashboard -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/51)
9+
10+
311
## 0.3.5 (2020-02-15)
412

513
Features:

src/main/java/main/controllers/AuditController.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,10 @@ public String create(boolean all, boolean xls) throws AqualityException {
134134
JSONArray resArray = new JSONArray();
135135
List<Pair<String, String>> fields = processExportArrayCreation(resArray, audits);
136136
try {
137-
138137
if (xls) {
139-
return excelUtils.writeXLSFile(resArray, fields, MessageFormat.format("Reporting_Portal_{0}_Submitted_Audits_{1}", all ? "All" : "Last", formatter.format(new Date())), MessageFormat.format("{0} Submitted Audits", all ? "All" : "Last"));
138+
return excelUtils.writeXLSFile(resArray, fields, MessageFormat.format("Aquality_Tracking_{0}_Submitted_Audits_{1}", all ? "All" : "Last", formatter.format(new Date())), MessageFormat.format("{0} Submitted Audits", all ? "All" : "Last"));
140139
} else {
141-
return excelUtils.writeXLSXFile(resArray, fields, MessageFormat.format("Reporting_Portal_{0}_Submitted_Audits_{1}", all ? "All" : "Last", formatter.format(new Date())), MessageFormat.format("{0} Submitted Audits", all ? "All" : "Last"));
140+
return excelUtils.writeXLSXFile(resArray, fields, MessageFormat.format("Aquality_Tracking_{0}_Submitted_Audits_{1}", all ? "All" : "Last", formatter.format(new Date())), MessageFormat.format("{0} Submitted Audits", all ? "All" : "Last"));
142141
}
143142
} catch (Exception e) {
144143
throw new AqualityException("Cannot create Export");
@@ -381,7 +380,7 @@ private List<Pair<String, String>> processExportArrayCreation(JSONArray resArray
381380

382381
return fields;
383382
} catch (Exception e) {
384-
throw new AqualityException("Cannot create Export");
383+
throw new AqualityException("Cannot process export creation");
385384
}
386385
}
387386
}

src/main/java/main/utils/ExcelUtils.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,42 +30,35 @@ public class ExcelUtils {
3030
private XSSFCell lastCell;
3131

3232
public String writeXLSFile(JSONArray objects, List<Pair<String, String>> fields, String fileName, String sheetName) throws IOException, JSONException {
33-
3433
final String path = PathUtils.createPathToBin("temp", "Exports");
3534
new File(path).mkdirs();
36-
3735
HSSFWorkbook wb = new HSSFWorkbook();
3836
HSSFSheet sheet = wb.createSheet(sheetName);
39-
4037
CreateHeadRow(sheet, fields);
4138
CreateRows(objects, sheet, fields);
4239
ColumnsAutoHeight(sheet, fields);
43-
4440
String fPath = PathUtils.createPath(path, fileName + ".xlsx");
4541
FileOutputStream fileOut = new FileOutputStream(fPath);
46-
4742
wb.write(fileOut);
4843
fileOut.flush();
4944
fileOut.close();
50-
5145
return fPath;
5246
}
5347

5448
public String writeXLSXFile(JSONArray objects, List<Pair<String, String>> fields, String fileName, String sheetName) throws IOException, JSONException {
55-
5649
final String path = PathUtils.createPathToBin("temp", "Exports");
5750
new File(path).mkdirs();
58-
5951
XSSFWorkbook wb = new XSSFWorkbook();
6052
XSSFSheet sheet = wb.createSheet(sheetName);
6153
CreateRows(objects, sheet, fields);
6254
ColumnsAutoHeight(sheet, fields);
55+
if(lastCell == null){
56+
lastCell = firstCell;
57+
}
6358

6459
sheet.setAutoFilter(new CellRangeAddress(firstCell.getRowIndex(), lastCell.getRowIndex(), firstCell.getColumnIndex(), lastCell.getColumnIndex()));
65-
6660
String fPath = PathUtils.createPath(path, fileName + ".xlsx");
6761
FileOutputStream fileOut = new FileOutputStream(fPath);
68-
6962
wb.write(fileOut);
7063
fileOut.flush();
7164
fileOut.close();

0 commit comments

Comments
 (0)