@@ -49,11 +49,10 @@ public abstract class SaveExcelObject<T> implements SaveExcel {
4949 protected Comparator <? super Object > c = null ;
5050 protected ResultSet resultSet = null ;
5151 protected OutputStream stream = null ;
52- protected Boolean isResponse = false ;
5352 protected Workbook wk = null ;
5453 protected HashMap <String , String > convert_title = new HashMap <>();
5554 protected HashMap <String , CellStyle > cell_style = new HashMap <>();
56- protected List <CellStyleCallbackInterface > cellStyleCallbackInterfaces = new ArrayList <>();
55+ private List <CellStyleCallbackWapper > cellStyleCallbackWappers = new ArrayList <>();
5756
5857
5958 public SaveExcelObject (List <T > list , String path ) {
@@ -81,10 +80,7 @@ public SaveExcelObject Filter(DataFilterInterface<?> filter) {
8180 }
8281
8382 protected Workbook createWK () throws Exception {
84- if (wk !=null ){
85- return wk ;
86- }
87- return wk = ExcelTool .newInstance (path .equals ("" ) ? DEFAULT_TYPE : path , true );
83+ return wk != null ? wk : (wk = ExcelTool .newInstance (path .equals ("" ) ? DEFAULT_TYPE : path , true ));
8884 }
8985
9086 @ Override
@@ -122,14 +118,8 @@ protected OutputStream createStream() throws Exception {
122118 return stream ;
123119 }
124120
125- /**
126- * TempName
127- */
128- private String title_ = null ;
129-
130121 protected String convertTitle (String title ) throws Exception {
131- title_ = null ;
132- title_ = convert_title .get (title );
122+ String title_ = convert_title .get (title );
133123 return title_ == null ? title : title_ ;
134124 }
135125
@@ -171,21 +161,21 @@ public SaveExcel ConvertName(HashMap<String, String> title_mapping, Boolean is_i
171161 }
172162
173163 @ Override
174- public SaveExcel SetCellStyle (String name , CellStyleInterface styleInterface ){
175- if (wk == null ){
176- cellStyleCallbackInterfaces .add (new CellStyleCallbackInterface (name ,styleInterface ));
164+ public SaveExcel SetCellStyle (String name , CellStyleInterface styleInterface ) {
165+ if (wk == null ) {
166+ cellStyleCallbackWappers .add (new CellStyleCallbackWapper (name , styleInterface ));
177167 return this ;
178168 }
179169 cell_style .put (name , styleInterface .create (CellStyle .CreateStyle (wk .createCellStyle ())));
180170 return this ;
181171 }
182172
183- protected void tryCreateCellStyle () throws Exception {
184- if (wk == null ){
173+ protected void tryCreateCellStyle () throws Exception {
174+ if (wk == null ) {
185175 throw new Exception ("请输入路径并且初始化WK对象" );
186176 }
187- for (CellStyleCallbackInterface c : cellStyleCallbackInterfaces ) {
188- c .create (wk ,cell_style );
177+ for (CellStyleCallbackWapper c : cellStyleCallbackWappers ) {
178+ c .create (wk , cell_style );
189179 }
190180 }
191181
@@ -198,12 +188,11 @@ public SaveExcel AnyCol(DataFilterColumnInterface df) {
198188 }
199189
200190
201-
202- protected void initTitle (String [] title , Row row , org .apache .poi .ss .usermodel .CellStyle defStyle ) throws Exception {
191+ protected void initTitle (String [] title , Row row , org .apache .poi .ss .usermodel .CellStyle defStyle ) throws Exception {
203192 for (short i = 0 ; i < title .length ; i ++) {
204193 Cell cell = row .createCell (i );
205194 cell .setCellStyle (defStyle );
206- if (cell_style .containsKey (title [i ])){
195+ if (cell_style .containsKey (title [i ])) {
207196 cell .setCellStyle (cell_style .get (title [i ]).getRealyStyle ());
208197 }
209198 cell .setCellValue (convertTitle (title [i ]));
0 commit comments