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

fix sharedString deletion #515

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add safeguard against workbooks without any shared strings
DavZim committed Dec 6, 2024
commit a722578b400b92ed1dc46e075baff4744078a6e9
19 changes: 11 additions & 8 deletions R/wrappers.R
Original file line number Diff line number Diff line change
@@ -1916,14 +1916,17 @@ deleteDataColumn <- function(wb, sheet, col) {
a$rows <- a$rows[keep]

# reduce the shared strings pointers if they are not used anymore
ss <- data.frame(
# the old index 0 indexed, as used in a$v
old = as.numeric(seq(length(wb$sharedStrings)) - 1),
# will hold the new index 0 indexed, as used in a$v
new = NA,
# the actual strings
string = wb$sharedStrings
)
ss <- data.frame(old = numeric(0), new = numeric(0), string = character(0))
if (length(wb$sharedStrings) > 0) {
ss <- data.frame(
# the old index 0 indexed, as used in a$v
old = as.numeric(seq(length(wb$sharedStrings)) - 1),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe seq_along(wb$sharedStrings) - 1

# will hold the new index 0 indexed, as used in a$v
new = NA,
# the actual strings
string = wb$sharedStrings
)
}

# 1. remove the values from sheet_data (a)
a$v <- a$v[keep]