bengbengbalabalabeng commented on issue #689:
URL: https://github.com/apache/fesod/issues/689#issuecomment-3537433246

   > [Writing Without Creating Objects] SimpleColumnWidthStyleStrategy can set 
a fixed width for all columns; Can automatic column span be set or width be set 
separately for each column?
   
   You can use `AbstractHeadColumnWidthStyleStrategy` to customize.
   
   Like:
   
   ```java
   class CustomColumnWidthStyleStrategy extends 
AbstractHeadColumnWidthStyleStrategy {
   
           private final Map<Integer, Integer> headWidthMap;
   
           CustomColumnWidthStyleStrategy(Map<Integer, Integer> headWidthMap) {
               this.headWidthMap = headWidthMap;
           }
   
           @Override
           protected Integer columnWidth(Head head, Integer columnIndex) {
               return headWidthMap.get(columnIndex);
           }
       }
   ```
   
   ```java
   List<List<String>> head = List.of(
              List.of("Number"),
              List.of("Name"),
              List.of("Age")
   );
   
   Map<Integer, Integer> headWidthMap = new HashMap<>();
   // for "Number"
   headWidthMap.put(0, 10);
   // for "Name"
   headWidthMap.put(1, 20);
   // for "Age"
   headWidthMap.put(2, 30);
   
   FastExcel.write(file)
                   .head(head)
                   .registerWriteHandler(new 
CustomColumnWidthStyleStrategy(headWidthMap))
                   .sheet()
                   .doWrite(Collections.emptyList());
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to