bdunkleysmith Active Member Licensed User Longtime User May 13, 2025 #1 I note in this library post XLUtils / jPOI 5 - Read and write MS Excel workbooks it says v1.12 - New methods and properties: XLSheetWriter.SetFitToPage, PrintSetup and PrintArea. however I can find no example of how the PrintSetup method is used. Currently when I create a workbook/worksheet with this library, the print setup dialog in Excel shows the page size as Letter, but I would like to set it to A4 programmatically rather than change to change it manually each time. I assumed using the PrintSetup method may be an appropriate way to do this. Any guidance would be appreciated.
I note in this library post XLUtils / jPOI 5 - Read and write MS Excel workbooks it says v1.12 - New methods and properties: XLSheetWriter.SetFitToPage, PrintSetup and PrintArea. however I can find no example of how the PrintSetup method is used. Currently when I create a workbook/worksheet with this library, the print setup dialog in Excel shows the page size as Letter, but I would like to set it to A4 programmatically rather than change to change it manually each time. I assumed using the PrintSetup method may be an appropriate way to do this. Any guidance would be appreciated.
Solution bdunkleysmith May 13, 2025 Looking at these references: https://poi.apache.org/apidocs/dev/org/apache/poi/xssf/usermodel/XSSFPrintSetup.html and https://poi.apache.org/apidocs/dev/org/apache/poi/ss/usermodel/PaperSize.html I found this code does the job: B4X: Copy Dim PrintSetup = sheet1.PrintSetup As JavaObject PrintSetup.RunMethod("setPaperSize", Array As Object("A4_PAPER"))
Looking at these references: https://poi.apache.org/apidocs/dev/org/apache/poi/xssf/usermodel/XSSFPrintSetup.html and https://poi.apache.org/apidocs/dev/org/apache/poi/ss/usermodel/PaperSize.html I found this code does the job: B4X: Copy Dim PrintSetup = sheet1.PrintSetup As JavaObject PrintSetup.RunMethod("setPaperSize", Array As Object("A4_PAPER"))
bdunkleysmith Active Member Licensed User Longtime User May 13, 2025 #2 Looking at these references: https://poi.apache.org/apidocs/dev/org/apache/poi/xssf/usermodel/XSSFPrintSetup.html and https://poi.apache.org/apidocs/dev/org/apache/poi/ss/usermodel/PaperSize.html I found this code does the job: B4X: Copy Dim PrintSetup = sheet1.PrintSetup As JavaObject PrintSetup.RunMethod("setPaperSize", Array As Object("A4_PAPER")) Upvote 0 Solution
Looking at these references: https://poi.apache.org/apidocs/dev/org/apache/poi/xssf/usermodel/XSSFPrintSetup.html and https://poi.apache.org/apidocs/dev/org/apache/poi/ss/usermodel/PaperSize.html I found this code does the job: B4X: Copy Dim PrintSetup = sheet1.PrintSetup As JavaObject PrintSetup.RunMethod("setPaperSize", Array As Object("A4_PAPER"))