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

Excel throws an error- "Removed Records: View from /xl/workbook.xml part (Workbook)" #792

Closed
chowmun63 opened this issue Sep 11, 2023 · 1 comment
Labels
bug 🐛 Something isn't working

Comments

@chowmun63
Copy link

chowmun63 commented Sep 11, 2023

I loaded a workbook from my local drive, delete a worksheet and save the workbook. When I tried to open the workbook by double-clicking the output file, Excel threw an error.

If I added a new worksheet, keeping the total number of worksheet same as the loaded workbook, no error was encountered.

The version of openxlsx2 is 1.0.
The version of R is 4.3.0.

Here is the reprex.

library(openxlsx2)
#> Warning: package 'openxlsx2' was built under R version 4.3.1

# Excel prompts error when the file is being opened
wb <- wb_load("test file.xlsx")
#> Error in wb_load("test file.xlsx"): File does not exist.
wb$get_sheet_names()
#> Error in eval(expr, envir, enclos): object 'wb' not found
wb$remove_worksheet(1)
#> Error in eval(expr, envir, enclos): object 'wb' not found
wb$get_sheet_names()
#> Error in eval(expr, envir, enclos): object 'wb' not found
wb_save(wb, "test_out.xlsx")
#> Error in eval(expr, envir, enclos): object 'wb' not found

# {no error
wb <- wb_load("test file.xlsx")
#> Error in wb_load("test file.xlsx"): File does not exist.
wb$get_sheet_names()
#> Error in eval(expr, envir, enclos): object 'wb' not found
wb$remove_worksheet(1)
#> Error in eval(expr, envir, enclos): object 'wb' not found
wb$get_sheet_names()
#> Error in eval(expr, envir, enclos): object 'wb' not found
wb$add_worksheet("new1")
#> Error in eval(expr, envir, enclos): object 'wb' not found
wb$get_sheet_names()
#> Error in eval(expr, envir, enclos): object 'wb' not found
wb_save(wb, "test_out.xlsx")
#> Error in eval(expr, envir, enclos): object 'wb' not found
# }

Created on 2023-09-11 with reprex v2.0.2
Excel's error message
test file.xlsx

@JanMarvin
Copy link
Owner

Hi @chowmun63 , thanks for the report. Looks like we do not pop the worksheet view when removing the worksheet.

@JanMarvin JanMarvin added the bug 🐛 Something isn't working label Sep 11, 2023
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

2 participants