jkmcl commented on PR #657:
URL: https://github.com/apache/poi/pull/657#issuecomment-2583546863

   @pjfanning May I ask why using the new method `setArbitraryExtraWidth` 
introduced by this PR makes no difference in the code below?
   
   ```java
   private static void createFile(Path path, boolean extraWidth) throws 
IOException {
       try (var workbook = new SXSSFWorkbook()) {
           var sheet = workbook.createSheet();
           if (extraWidth) {
               // *** Call the new method here ***
               
sheet.setArbitraryExtraWidth(SheetUtil.getDefaultCharWidthAsFloat(workbook) * 
2);
           }
           sheet.trackColumnForAutoSizing(0);
   
           var row = sheet.createRow(0);
           row.createCell(0).setCellValue("This is a very long text that will 
exceed default column width for sure.");
           sheet.autoSizeColumn(0);
   
           try (var stream = Files.newOutputStream(path)) {
               workbook.write(stream);
           }
       }
   }
   
   @Test
   void mainTest() throws IOException {
       var outDir = Path.of("target/test-output");
       Files.createDirectories(outDir);
   
       createFile(outDir.resolve("no_extra_width.xlsx"), false);
       createFile(outDir.resolve("extra_width.xlsx"), true);
   }
   ```
   
   The above `@Test` method creates two files with almost the same code path 
except that `setArbitraryExtraWidth` is not called when creating 
`no_extra_width.xlsx`. I was expecting the width of the first column in this 
file to be shorter but it turned out to be the same in both files:
   
   
![image](https://github.com/user-attachments/assets/cebda098-beb8-4b2d-9425-f87e4034268b)
   
   Does some condition need to be met for the extra width to be honored?
   
   FYI, I ran the code on a Windows 10 machine with Eclipse Temurin JDK 
17.0.13. The complete Maven project containing the code can be found here: 
https://github.com/jkmcl/poi-sample
   
   Thanks.


-- 
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: dev-unsubscr...@poi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to