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
Closed
Changes from all commits
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
1 change: 1 addition & 0 deletions src/Codec/Xlsx/Formatted.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.

cs' <- forM (M.toList fcs) $ \(rc, fc) -> formatCell rc fc
merges <- reverse . _formattingMerges <$> get
return ( name
Expand Down