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

   > This issue would be best served by providing a simple and executable 
sample code.
   
   @delei  Thanks for the feedback. I’ll make sure to provide a proposal first 
next time.
   
   ### Proposal
   
   This proposal introduces support for Multi-row Loop Filling restricted to 
the VERTICAL direction. It addresses the limitation where multi-row templates 
or merged regions were incorrectly overwritten during iteration.
   
   - Multi-row loop filling.
   - Cell merge handling.
   
   ### API Usage Example
   
   #### 1. Basic multi-row loop filling
   
   Filling a multi-row template without special merge strategies.
   
   - Prepare to fill the template:
   
   <img width="1003" height="172" alt="Image" 
src="https://github.com/user-attachments/assets/eefcb11c-fbf5-4f41-b74e-0eb859e5f338";
 />
   
   <details>
   
   <summary>Click to review full code</summary>
   
   - Define excel model:
   
   ```java
   @Data
   public class ExcelModel {
       
       private Integer no;
   
       private String code;
   
       private String label;
   
       private String name1;
   
       private String name2;
   
       private String totalCount;
   
       private String totalWeight;
   
       private String count1;
   }
   ```
   
   - Demo:
   
   ```java
   FesodSheet.write("/pathname/output.xlsx")
       .withTemplate("/pathname/template.xlsx")
       .head(ExcelModel.class)
       .sheet()
       .doFill(datas(), FillConfig.builder().build());
   ```
   
   </details>
   
   - Output:
   
   <img width="742" height="282" alt="Image" 
src="https://github.com/user-attachments/assets/f1a9c74e-dc36-49e7-8385-9ba476e2bc2f";
 />
   
   #### 2. Multi-row filling with auto merge
   
   Automatically handling merged regions based on template cell.
   
   - Prepare to fill the template:
   
   <img width="1003" height="172" alt="Image" 
src="https://github.com/user-attachments/assets/83069971-fd8c-41ca-bebd-ff3f93e5ab04";
 />
   
   <details>
   
   <summary>Click to review full code</summary>
   
   - Define excel model:
   
   ```java
   @Data
   public class ExcelModel {
       
       private Integer no;
   
       private String code;
   
       private String label;
   
       private String name1;
   
       private String name2;
   
       private String totalCount;
   
       private String totalWeight;
   
       private String count1;
   }
   ```
   
   - Demo:
   
   ```java
   FesodSheet.write("/pathname/output.xlsx")
       .withTemplate("/pathname/template.xlsx")
       .head(ExcelModel.class)
       .sheet()
       // Use FillMergeStrategy.AUTO to handle merge regions
       .doFill(datas(), 
FillConfig.builder().mergeStrategy(FillMergeStrategy.AUTO).build());
   ```
   
   </details>
   
   - Output:
   
   <img width="1011" height="316" alt="Image" 
src="https://github.com/user-attachments/assets/62e25a53-a297-4e58-8233-cdfee5f1e55a";
 />
   
   #### 3. Multi-row loop filling with auto merge and copy merged regions 
cell-styles
   
   Copying cell styles for merged regions (High Overhead).
   
   > NOTE
   > 1. **This solution is currently under verification.**
   > 2. **Excessive cell-styles may cause performance issues.**
   
   - Prepare to fill the template:
   
   <img width="771" height="151" alt="Image" 
src="https://github.com/user-attachments/assets/bd487b88-3b4d-4361-bb9b-567d9fe8fd0c";
 />
   
   <details>
   
   <summary>Click to review full code</summary>
   
   - Define excel model:
   
   ```java
   @Data
   public class ExcelModel {
       
       private Integer no;
   
       private String code;
   
       private String label;
   
       private String name1;
   
       private String name2;
   
       private String totalCount;
   
       private String totalWeight;
   
       private String count1;
   }
   ```
   
   - Demo:
   
   ```java
   FesodSheet.write("/pathname/output.xlsx")
       .withTemplate("/pathname/template.xlsx")
       .head(ExcelModel.class)
       .sheet()
       // Use FillMergeStrategy.MERGE_CELL_STYLE to handle merge regions and 
applies styles to the entire merged region
       .doFill(datas(), 
FillConfig.builder().mergeStrategy(FillMergeStrategy.MERGE_CELL_STYLE).build());
   ```
   
   </details>
   
   - Output:
   
   <img width="741" height="256" alt="Image" 
src="https://github.com/user-attachments/assets/204a44eb-8965-44cb-8c33-fdf3cbef32f8";
 />


-- 
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