awalker89 / openxlsx

R package for .xlsx file reading and writing.
Other
363 stars 79 forks source link

Feature request - Add print areas and PrintTitleColumns #534

Closed AlvaroMCMC closed 2 years ago

AlvaroMCMC commented 2 years ago

These features are present in VBA, to the people who know it it's ok, but for the rest of us, it would be awesome to have it all with R.

This is an example with VBA code. As you see there are printTitleColumns and PrintArea (multipage A3), the main features request.

Sub print_area()
    Dim ws As Worksheet

    For Each ws In ActiveWorkbook.Worksheets
        With ws.PageSetup
            .PrintTitleColumns = "$A:$E"
            .PrintArea = "$F$1:$AF$125,$AG$1:$BE$125,$BF$1:$CD$125,$CE$1:$DA$125,$DB$1:$DX$125" ' there will be one area between the upper left and lower right cells
            Debug.Print .PrintArea  ' check the final .PrintArea; prints $F$1:$DX$125
            .Zoom = False
            .Orientation = xlLandscape
            .FitToPagesWide = False 'it's Auto
            .FitToPagesTall = 1
            .CenterHorizontally = True
            ws.ResetAllPageBreaks
            breaks = Array("AF1", "BE1", "CD1", "DA1", "DX1")   'zero-based array
            For i = 1 To UBound(breaks)
                ws.VPageBreaks.Add Before:=ws.Range(breaks(i - 1)).Offset(, 1)
            Next
        End With
    Next
End Sub

Thanks.

ycphs commented 2 years ago

Could you please create an issue at ycphs/openxlsx?

This is the active fork of the package.

AlvaroMCMC commented 2 years ago

It's already created there. I will close this. Tkz.