Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write uninitalized row to output #476

Open
JanMarvin opened this issue Dec 15, 2022 · 1 comment
Open

Write uninitalized row to output #476

JanMarvin opened this issue Dec 15, 2022 · 1 comment
Labels
bug 🐛 Something isn't working

Comments

@JanMarvin
Copy link
Owner

JanMarvin commented Dec 15, 2022

Currently, when writing output, we force a cell <c/> node on every row <row/> we write. Working on #475 I created the attached file that breaks this logic. I assume our logic checks rows against cells because I ran into some other issues when developing xml writing logic or creating, copying or updating cells.

The issue is quite minor, but affects all uninitialized rows (open a worksheet in Excel, hide a row. Save the file, load it in openxlsx2 and the hidden row is back, because it was never written to our output in the first place). To fix this, someone, i.e. me, would have to rework the write logic, and (a) I don't want to do that right now and (b) something else might break in the process. For now this is a known defect, but nothing I'm actively working on.

The example file below:
In Excel two rows are available, but no cells at all. All other rows are hidden (using <sheetFormatPr zeroHeight=\"1\" />).

library(openxlsx2)

wb <- wb_load("/tmp/xlsx.xlsx")

wb$worksheets[[1]]$sheet_data$row_attr
#>   collapsed customFormat customHeight hidden ht outlineLevel ph r s spans
#> 0                                                               1        
#> 1                                                               2        
#>   thickBot thickTop x14ac:dyDescent
#> 0                               0.2
#> 1                               0.2
wb$worksheets[[1]]$sheet_data$cc
#>  [1] r     row_r c_r   c_s   c_t   c_cm  c_ph  c_vm  v     f     f_t   f_ref
#> [13] f_ca  f_si  is   
#> <0 rows> (or 0-length row.names)

wb$save("/tmp/test.xlsx")

wb <- wb_load("/tmp/test.xlsx")

wb$worksheets[[1]]$sheet_data$row_attr
#>  [1] collapsed       customFormat    customHeight    hidden         
#>  [5] ht              outlineLevel    ph              r              
#>  [9] s               spans           thickBot        thickTop       
#> [13] x14ac:dyDescent
#> <0 rows> (or 0-length row.names)
wb$worksheets[[1]]$sheet_data$cc
#>  [1] r     row_r c_r   c_s   c_t   c_cm  c_ph  c_vm  v     f     f_t   f_ref
#> [13] f_ca  f_si  is   
#> <0 rows> (or 0-length row.names)

xlsx.xlsx

@JanMarvin JanMarvin added bug 🐛 Something isn't working wontfix 🚫 This will not be worked on labels Dec 15, 2022
@JanMarvin
Copy link
Owner Author

JanMarvin commented Dec 15, 2022

Maybe a cheap workaround: initialize a cell for all imported rows even if they are not available in the input. The result should be identical from the users point of view. All it needs is a check at the end of wb_load() and a call to initializeCell().

@JanMarvin JanMarvin removed the wontfix 🚫 This will not be worked on label Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant