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

Checkboxes (mc:AlternateContent + mc:Choice) #1162

Closed
Ralim opened this issue Mar 1, 2022 · 2 comments
Closed

Checkboxes (mc:AlternateContent + mc:Choice) #1162

Ralim opened this issue Mar 1, 2022 · 2 comments

Comments

@Ralim
Copy link

Ralim commented Mar 1, 2022

Description
Hello,

Not sure if this is a bug, missing feature, out of scope, or covered under the planned features. (My knowledge of Excel files isnt great yet).

I have an old file that has been converted up to xlsx from who knows what versions of excel before it.

Inside spreadsheets and drawings xml files it has the tags for mc:AlternateContent & mc:Choice which appear to be related to the checkboxes from my testing.

It looks like these are being dropped when the file is run through Excelize. I'm guessing that adding support for persisting these through is a fair bit of work though.

These are interesting, as if I open the file post-excelize in Excel on Mac OS X then the checkboxes are either in the wrong location or missing.
Whereas, if I open first on a Windows 10 install, and save. Then everything works just fine.

So I'm inclined to think these are computed values rather than the "truth" data for these items, but also unsure if there is anything that can be done in Excelize about this?

If this is mostly a matter of having to create a bunch of struct definitions, just point me to where i can look them up and I'm happy to make them / try for a PR.

Steps to reproduce the issue:

Please let me know if this is confusing and ill try and create a small repro file for you, haven't been able to make one in 15 minutes (yet).

Describe the results you received:

In a drawing file (such as ./xl/drawings/drawing2.xml)

The wrapping two tags and the Fallback tag appear to disappear?

Input:
<mc:AlternateContent xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
        <mc:Choice xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" Requires="a14">
            <xdr:twoCellAnchor editAs="absolute">
                <...Removed for simplicity>
            </xdr:twoCellAnchor>
        </mc:Choice>
        <mc:Fallback/>
    </mc:AlternateContent>
    
    output:
     <xdr:twoCellAnchor editAs="absolute">
                <...Removed for simplicity>
            </xdr:twoCellAnchor>

In the sheetX.xml files instead, these sections are entirely removed from the end of the file:

<mc:AlternateContent xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
                    <mc:Choice Requires="x14">
                        <control shapeId="33206" r:id="rId38" name="Button 404">
                            <controlPr defaultSize="0" print="0" autoFill="0" autoPict="0" macro="[0]!Snip">
                                <anchor moveWithCells="1" sizeWithCells="1">
                                    <from>
                                        <xdr:col>11</xdr:col>
                                        <xdr:colOff>0</xdr:colOff>
                                        <xdr:row>80</xdr:row>
                                        <xdr:rowOff>0</xdr:rowOff>
                                    </from>
                                    <to>
                                        <xdr:col>13</xdr:col>
                                        <xdr:colOff>0</xdr:colOff>
                                        <xdr:row>81</xdr:row>
                                        <xdr:rowOff>0</xdr:rowOff>
                                    </to>
                                </anchor>
                            </controlPr>
                        </control>
                    </mc:Choice>
                </mc:AlternateContent>

Describe the results you expected:
Output ~= Input
Output of go version:

go version go1.17.4 linux/arm64

Excelize version or commit ID:

	github.com/xuri/excelize/v2 v2.5.0

Environment details (OS, Microsoft Excel™ version, physical, etc.):

Tested on Linux and Mac OSX; go 1.17 and 1.18.
Files are edited with latest office365.

Notes

Happy to help in any way I can for this :)

@xuri
Copy link
Member

xuri commented Mar 4, 2022

Thanks for your issue. The position and size are may be different under a different OS, the reason for that was similar to issue #212. I'll evaluate recently to add preserve support for existing alternate content in drawingML.

@xuri xuri closed this as completed in f0cb29c Mar 5, 2022
@Ralim
Copy link
Author

Ralim commented Mar 5, 2022

Awesome, thank you soo much.
Will test and confirm on Monday ❤️

xuri added a commit to carbin-gun/excelize that referenced this issue Oct 9, 2022
…tent

Preserve alternate content in the workbook, worksheet, and drawingML
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
…tent

Preserve alternate content in the workbook, worksheet, and drawingML
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

No branches or pull requests

2 participants