@@ -241,13 +241,11 @@ protected List<Tr> createThead() {
241241 }
242242 tdLists .add (tds );
243243 }
244-
245244 // 调整rowSpan
246245 for (List <Td > tdList : tdLists ) {
247246 Td last = tdList .get (tdList .size () - 1 );
248247 last .setRowSpan (titleLevel - last .row );
249248 }
250-
251249 // 调整colSpan
252250 for (int i = 0 ; i < titleLevel ; i ++) {
253251 int level = i ;
@@ -300,15 +298,15 @@ protected List<Tr> createThead() {
300298 boolean isComputeAutoWidth = WidthStrategy .isComputeAutoWidth (configuration .widthStrategy );
301299 rowTds .forEach ((k , v ) -> {
302300 Tr tr = new Tr (k , configuration .titleRowHeight );
303- tr .colWidthMap = isComputeAutoWidth ? new HashMap <>(titles .size ()) : Collections .emptyMap ();
304- List < Td > tds = v .stream ().sorted (Comparator .comparing (td -> td .col ))
301+ tr .colWidthMap = isComputeAutoWidth || ! customWidthMap . isEmpty () ? new HashMap <>(titles .size ()) : Collections .emptyMap ();
302+ tr . tdList = v .stream ().sorted (Comparator .comparing (td -> td .col ))
305303 .peek (td -> {
306304 if (isComputeAutoWidth ) {
307305 tr .colWidthMap .put (td .col , TdUtil .getStringWidth (td .content , 0.25 ));
308306 }
309307 })
310308 .collect (Collectors .toList ());
311- tr .tdList = tds ;
309+ tr .colWidthMap . putAll ( customWidthMap ) ;
312310 trs .add (tr );
313311 });
314312 return trs ;
@@ -344,7 +342,7 @@ protected Tr createTr(List<Pair<? extends Class, ?>> contents) {
344342 this .setTdWidth (tr .colWidthMap , td );
345343 return td ;
346344 }).collect (Collectors .toList ());
347- customWidthMap . forEach ( tr .colWidthMap :: put );
345+ tr .colWidthMap . putAll ( customWidthMap );
348346 tr .tdList = tdList ;
349347 return tr ;
350348 }
0 commit comments