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 Accumulating Cell Merge Info While formatWorkbook #143

Closed
wants to merge 1 commit into from

Conversation

vst
Copy link

@vst vst commented Aug 12, 2021

This PR closes #142.

formatWorkbook accumulates cell merge information (_formattingMerges) along with style information as it iterates over a list of worksheet data.

Indeed, this is necessary for formatCell to process a single worksheet and to conclude with a list of cell ranges for merged cells.

However, once we are done with processing a single worksheet, we should reset the accumulated merge information to an empty list so that the next worksheet does not contain cell merges accumulated from previous worksheets' data.

@@ -251,6 +251,7 @@ formatWorkbook nfcss initStyle = extract go
initSt = stateFromStyleSheet initStyle
go = flip runState initSt $
forM nfcss $ \(name, fcs) -> do
modify (\s -> s { _formattingMerges = [] }) -- We do not want merge information to accumulate across sheets.
Copy link
Owner

Choose a reason for hiding this comment

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

Hi @vst
Thanks for the issue and the PR
Your fix does resolve the problem but I think that we fix the root of this problem and not just use this workaround.
I think that the main issue here is that Formatted should be probably named something like FormattedSheet because while it contains workbook level style sheet at the same time it includes worksheet level data - cells and merges. And thus forM use in this go helper isn't a quite correct thing - the code shouldn't start with some data form the previous worksheet.
Would you like to work on a better fix here? And if we need to rename some types we could release it as a new major version of the library.
In any case thanks for the contribution

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for quick response, @qrilka.

I agree with you. It must be more coherent.

I would love to work on it as you suggested, but I can not promise a target date within the next few weeks.

  • You may wish to close this PR. I can leave some instructions to the related issue for current users so that they can live with the current version until we implement a proper fix.
  • You may merge this as an interim solution, but I am afraid of inertia it may cause :)
  • In the meantime, I will study the code, play with the types and ways to avoid what forM does as you suggested.

Copy link
Owner

Choose a reason for hiding this comment

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

I think there's no rush so you could take your time, thanks.

@qrilka
Copy link
Owner

qrilka commented Jul 8, 2023

@vst I'm going to close this PR as no longer active, please shout if you need it to be reopened

@qrilka qrilka closed this Jul 8, 2023
@vst
Copy link
Author

vst commented Jul 8, 2023

Alright. Sorry, I did not have time to look into that. I will ping you if I can look at it.

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.

Leaking merge information across worksheets
2 participants