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

dataset template workflow cannot preserve rich text cells #119

Open
tgbugs opened this issue Sep 16, 2024 · 1 comment
Open

dataset template workflow cannot preserve rich text cells #119

tgbugs opened this issue Sep 16, 2024 · 1 comment

Comments

@tgbugs
Copy link
Collaborator

tgbugs commented Sep 16, 2024

It is not possible to use a combination of openpyxl and libreoffice calc and preserve inline formatting for cells. This is because openpyxl has dropped support for xl/sharedStrings.xml and localc always saves xlsx files using xl/sharedStrings.xml even if the inline formatting was originally saved in xl/worksheets/sheet1.xml. This currently impacts code_description.xlsx which has lost some of its formatting.

There is nothing to do about this right now other than point the projects at it and point out that it is currently impossible to roundtrip data when using both of their tools.

@tgbugs
Copy link
Collaborator Author

tgbugs commented Sep 16, 2024

The test code needed in datasets.Tabular._openpyxl_fixes to illustrate the issue:

            if self.path.stem == 'code_description':
                import openpyxl.cell.rich_text as rt
                import openpyxl.cell.text as tx
                b7 = _sheet.cell(7, 2)
                def bold(text, cell=b7):
                    kwargs = {**cell.font.__dict__}
                    kwargs['rFont'] = kwargs.pop('name')
                    kwargs['b'] = True
                    return rt.TextBlock(tx.InlineFont(**kwargs), text)

                def italic(text, cell=b7):
                    kwargs = {**cell.font.__dict__}
                    kwargs['rFont'] = kwargs.pop('name')
                    kwargs['i'] = True
                    return rt.TextBlock(tx.InlineFont(**kwargs), text)

                t = rt.CellRichText('Column type. Valid values are: ', bold('Link'), ', ', bold('Text'), ', ', bold('Rating'), ', ', bold('Target'), ', ', bold('Target Justification'))
                b7.value = t
                #breakpoint()

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

No branches or pull requests

1 participant