loadWorkbook returns a workbook object conserving styles and formatting of the original .xlsx file.
loadWorkbook(file, xlsxFile = NULL, isUnzipped = FALSE, na.convert = TRUE)
Workbook object.
## load existing workbook from package folder
wb <- loadWorkbook(file = system.file("extdata", "loadExample.xlsx", package = "openxlsx"))
names(wb) # list worksheets
#> [1] "IrisSample" "testing" "mtcars" "mtCars Pivot"
wb ## view object
#> A Workbook object.
#>
#> Worksheets:
#> Sheet 1: "IrisSample"
#>
#> Custom row heights (row: height)
#> 1: 34.5
#> Custom column widths (column: width)
#> 1: 10.86, 2: 10.43, 3: 10.86, 4: 10.43, 5: 13.14, 7: 12.43, 8: 18.43, 9: 18.00, 10: 18.14, 11: 17.71, 12: 9.715
#>
#>
#> Sheet 2: "testing"
#>
#> Custom row heights (row: height)
#> 7: 24, 8: 15.75, 20: 15.75, 27: 15.75, 28: 15.75, 29: 16.5, 31: 15.75, 33: 15.75, 35: 15.75, 36: 16.5, 37: 15.75, 38: 15.75
#> Custom column widths (column: width)
#> 9: 13.00, 10: 13.00, 11: 13.00, 12: 13.00, 13: 13.00, 14: 13.00
#>
#>
#> Sheet 3: "mtcars"
#>
#>
#> Sheet 4: "mtCars Pivot"
#>
#> Custom column widths (column: width)
#> 1: 12.43, 2: 14.29, 3: 8.860, 4: 9.145, 5: 9.145
#>
#>
#>
#>
#> Images:
#> Image 1: "/tmp/RtmpHTgXDc/file18d2415a985b/xl/media/image2.jpeg"
#> Image 2: "/tmp/RtmpHTgXDc/file18d2415a985b/xl/media/image1.jpeg"
#>
#> Charts:
#> Chart 1: "/tmp/RtmpHTgXDc/file18d2415a985b/xl/charts/colors2.xml"
#> Chart 2: "/tmp/RtmpHTgXDc/file18d2415a985b/xl/charts/style2.xml"
#> Chart 3: "/tmp/RtmpHTgXDc/file18d2415a985b/xl/charts/chart2.xml"
#> Chart 4: "/tmp/RtmpHTgXDc/file18d2415a985b/xl/charts/chart1.xml"
#> Chart 5: "/tmp/RtmpHTgXDc/file18d2415a985b/xl/charts/style1.xml"
#> Chart 6: "/tmp/RtmpHTgXDc/file18d2415a985b/xl/charts/colors1.xml"
#> Chart 7: "/tmp/RtmpHTgXDc/file18d2415a985b/xl/charts/_rels/chart2.xml.rels"
#> Chart 8: "/tmp/RtmpHTgXDc/file18d2415a985b/xl/charts/_rels/chart1.xml.rels"
#> Worksheet write order: 1, 2, 3, 4
#> Active Sheet 2: "testing"
#> Position: 2
#>
## Add a worksheet
addWorksheet(wb, "A new worksheet")
## Save workbook
if (FALSE) { # \dontrun{
saveWorkbook(wb, "loadExample.xlsx", overwrite = TRUE)
} # }