Removing blank rows and columns from a worksheet #1100
Replies: 2 comments 3 replies
-
Hi @Jeff-White-AZ , I don’t understand this
Are these columns and rows part of the data frame or of the workbook? Is only the dimension tag in the worksheet set to “A1:Z9999” or is every cell available in the It’s correct though, that removing columns and rows is not possible with the package. |
Beta Was this translation helpful? Give feedback.
-
First to note that I just tested this problem again with Google Sheets. The default sheet has dimensions of A1:Z999, but in my test case, I only entered data from A1:C10. Upon downloading as xlsx, re-opening with Excel, and typing ctrl-end (to reach the "end" of the workbook), the cell C10 is active, so Google or MS has improved the behavior of the downloaded files.
|
Beta Was this translation helpful? Give feedback.
-
I am working with spreadsheets that often pass through Google Sheets. Google Sheets has the annoying tendency to default to a sheet extent from A1 to Z999. Once downloaded to Excel, if you add data of, for example, 8 columns and 100 rows, manipulate the data as needed with openxlsx2 as a data frame, and write the data back, the blank rows and columns remain because they are still part of the worksheet defined in the wb.
Based on my previous experience with openxlsx2 and searching the documentation, it appears that there is no simple way to directly delete rows or columns from a worksheet.
The option I can see is to read the information from the worksheet, delete the worksheet with wb_remove_worksheet(), and then rebuild the worksheet. However, the worksheets have a fair amount of formatting, that I would prefer not to have to reconstruct.
Is there a simpler approach? Have I missed something?
Beta Was this translation helpful? Give feedback.
All reactions