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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

fix sharedString deletion #515

wants to merge 2 commits into from

Conversation

DavZim
Copy link
Contributor

@DavZim DavZim commented Dec 6, 2024

Fixes #514

Also adds additional tests for the shared string usecase.

Makes the deleteDataColumn code a little bit easier to read and maintain.

Fixes another bug with sharedStrings across sheets. Now sharedStrings are fixed on a workbook-level and not sheet-level.

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

@@ -17,7 +17,7 @@ test_that("int2col and col2int", {
test_that("deleteDataColumn basics", {
wb <- createWorkbook()
addWorksheet(wb, "tester")

Copy link
Collaborator

Choose a reason for hiding this comment

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

unintended whitespace changes in the test file

@JanMarvin
Copy link
Collaborator

Hi @DavZim , thanks for taking care of the issue. Much appreciated!

Maybe one idea, you resize shared strings and subsequently have to update all references in all sheets. Is that required? Can't we just leave shared strings as is, or replace the removed strings with blanks or NA_character_, so that we do not have to adjust every shared strings entry?

@DavZim
Copy link
Contributor Author

DavZim commented Dec 6, 2024

Good question, I didn't think of this. Is it maybe worth adding it behind a function argument? Or do you think it's such an edge case that its better to keep shared strings anyways?

@JanMarvin
Copy link
Collaborator

I doubt that it’s required to add new arguments for this, but I haven’t checked the impact yet. Aka what spreadsheet software does if some shared string entry isn’t used. Unless the shared strings are very long or very many, the impact on the file size should be negligible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

deleteDataColumn adds strings in wrong places
2 participants