@@ -30,42 +30,35 @@ public class ExcelUtils {
30
30
private XSSFCell lastCell ;
31
31
32
32
public String writeXLSFile (JSONArray objects , List <Pair <String , String >> fields , String fileName , String sheetName ) throws IOException , JSONException {
33
-
34
33
final String path = PathUtils .createPathToBin ("temp" , "Exports" );
35
34
new File (path ).mkdirs ();
36
-
37
35
HSSFWorkbook wb = new HSSFWorkbook ();
38
36
HSSFSheet sheet = wb .createSheet (sheetName );
39
-
40
37
CreateHeadRow (sheet , fields );
41
38
CreateRows (objects , sheet , fields );
42
39
ColumnsAutoHeight (sheet , fields );
43
-
44
40
String fPath = PathUtils .createPath (path , fileName + ".xlsx" );
45
41
FileOutputStream fileOut = new FileOutputStream (fPath );
46
-
47
42
wb .write (fileOut );
48
43
fileOut .flush ();
49
44
fileOut .close ();
50
-
51
45
return fPath ;
52
46
}
53
47
54
48
public String writeXLSXFile (JSONArray objects , List <Pair <String , String >> fields , String fileName , String sheetName ) throws IOException , JSONException {
55
-
56
49
final String path = PathUtils .createPathToBin ("temp" , "Exports" );
57
50
new File (path ).mkdirs ();
58
-
59
51
XSSFWorkbook wb = new XSSFWorkbook ();
60
52
XSSFSheet sheet = wb .createSheet (sheetName );
61
53
CreateRows (objects , sheet , fields );
62
54
ColumnsAutoHeight (sheet , fields );
55
+ if (lastCell == null ){
56
+ lastCell = firstCell ;
57
+ }
63
58
64
59
sheet .setAutoFilter (new CellRangeAddress (firstCell .getRowIndex (), lastCell .getRowIndex (), firstCell .getColumnIndex (), lastCell .getColumnIndex ()));
65
-
66
60
String fPath = PathUtils .createPath (path , fileName + ".xlsx" );
67
61
FileOutputStream fileOut = new FileOutputStream (fPath );
68
-
69
62
wb .write (fileOut );
70
63
fileOut .flush ();
71
64
fileOut .close ();
0 commit comments