hide all rows after row X
Asked Answered
T

0

7

Is it possible to hide all rows in a worksheet after a specified row?

library("openxlsx")

# Create a workbook.
wb <- createWorkbook()

# Add a worksheet.
addWorksheet(wb, sheetName = "test", gridLines = FALSE)

# "Hide" all rows after row 37.
setRowHeights(wb, 1, 38:1048576, 0)

# Write workbook.
saveWorkbook(wb, "test.xlsx", overwrite = TRUE)

# inspect file size.
file.info("test.xlsx")
#              size isdir mode               mtime               ctime               atime exe
# test.xlsx 2621280 FALSE  666 2018-09-13 14:54:10 2018-09-13 14:54:07 2018-09-13 14:54:07  no

Seems very inefficient and seems to make the output extremely large (and slow when trying to open it in Excel). I assume it's not hiding it and in fact just changing row heights to be 0?

Tetany answered 13/9, 2018 at 4:57 Comment(3)
Yeah, you're correct, hidden isn't implemented for setRowHeights, retracting my vote to closeHebbe
You might look into trying to set the hidden attribute for rows like it works for columns, but I'm not sure if simply setting the attribute is enough. This is how it's set for columns: attr(wb$colWidths[[sheet]], "hidden") <- as.character(as.integer(hidden))Hebbe
Depending on what your workflow looks like, you could also restrict the visible area using the VBA scrollarea option. It's possible to pass a VBA script to shell() if you want to keep everything in RHebbe

© 2022 - 2024 — McMap. All rights reserved.