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

feature: worksheet AddButton #1169

Closed
JDavidVR opened this issue Mar 5, 2022 · 0 comments
Closed

feature: worksheet AddButton #1169

JDavidVR opened this issue Mar 5, 2022 · 0 comments
Labels
enhancement New feature or request
Projects

Comments

@JDavidVR
Copy link
Contributor

JDavidVR commented Mar 5, 2022

I've reviewed documentation, and there is no information about inserting a button to xlsx file

I did some research and here is a good example to have a buttom: https://xlsxwriter.readthedocs.io/example_macros.html

So these are my findings:

Buttons are added in this file: xl/drawings/vmlDrawing1.vml

<xml xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"
     xmlns:x="urn:schemas-microsoft-com:office:excel">
    <o:shapelayout v:ext="edit">
        <o:idmap v:ext="edit" data="1"/>
    </o:shapelayout>
    <v:shapetype id="_x0000_t201" coordsize="21600,21600" o:spt="201" path="m,l,21600r21600,l21600,xe">
        <v:stroke joinstyle="miter"/>
        <v:path shadowok="f" o:extrusionok="f" strokeok="f" fillok="f" o:connecttype="rect"/>
        <o:lock v:ext="edit" shapetype="t"/>
    </v:shapetype>
    <v:shape id="_x0000_s1025" type="#_x0000_t201"
             style="position:absolute;margin-left:161.25pt;margin-top:30pt;width:60pt;height:22.5pt;z-index:1;mso-wrap-style:tight"
             o:button="t" fillcolor="buttonFace [67]" strokecolor="windowText [64]" o:insetmode="auto">
        <v:fill color2="buttonFace [67]" o:detectmouseclick="t"/>
        <o:lock v:ext="edit" rotation="t"/>
        <v:textbox style="mso-direction-alt:auto" o:singleclick="f">
            <div style="text-align:center">
                <font face="Calibri" size="220" color="#000000">Press Me</font>
            </div>
        </v:textbox>
        <x:ClientData ObjectType="Button">
            <x:Anchor>1, 0, 2, 0, 2, 16, 3, 10</x:Anchor>
            <x:PrintObject>False</x:PrintObject>
            <x:AutoFill>False</x:AutoFill>
            <x:FmlaMacro>[0]!say_hello</x:FmlaMacro>
            <x:TextHAlign>Center</x:TextHAlign>
            <x:TextVAlign>Center</x:TextVAlign>
        </x:ClientData>
    </v:shape>
</xml>

Values that are dynamics are those:

<v:shape id="_x0000_s1025"` dynamic
<v:shape style="
                margin-left:%.15gpt; dynamic
                margin-top:%.15gpt; dynamic
                width:%.15gpt; dynamic
                height:%.15gpt; dynamic
                z-index:%d; dynamic
<v:textbox>
                <div>
                                <font>Press Me</font> dynamic
<x:ClientData >
                <x:Anchor>1, 0, 2, 0, 2, 16, 3, 10</x:Anchor> dynamic
                <x:FmlaMacro>[0]!say_hello</x:FmlaMacro> dynamic

I can work on implementation but I need some guidelines, like if I should create a new go file called, button.go and a tamplate in templates.go

@xuri xuri added the enhancement New feature or request label Mar 6, 2022
xuri added a commit to JDavidVR/excelize that referenced this issue Jul 11, 2023
- Breaking changes:
* Change
    `func (f *File) AddShape(sheet, cell string, opts *Shape) error`
    to
    `func (f *File) AddShape(sheet string, opts *Shape) error`
* Rename the `Runs` field to `Paragraph` in the exported `Comment` data type
- Add new exported function `AddFormControl` support to add button and radio form controls
- Add check for shape type for the `AddShape` function, an error will be returned if no shape type is specified
- Updated functions documentation and the unit tests
xuri added a commit to JDavidVR/excelize that referenced this issue Jul 11, 2023
- Breaking changes:
* Change
    `func (f *File) AddShape(sheet, cell string, opts *Shape) error`
    to
    `func (f *File) AddShape(sheet string, opts *Shape) error`
* Rename the `Runs` field to `Paragraph` in the exported `Comment` data type
- Add new exported function `AddFormControl` support to add button and radio form controls
- Add check for shape type for the `AddShape` function, an error will be returned if no shape type is specified
- Updated functions documentation and the unit tests
@xuri xuri closed this as completed in 2c8dc5c Jul 11, 2023
@xuri xuri added this to Features in v2.8.0 Jul 11, 2023
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
…os#1181)

- Breaking changes:
* Change
    `func (f *File) AddShape(sheet, cell string, opts *Shape) error`
    to
    `func (f *File) AddShape(sheet string, opts *Shape) error`
* Rename the `Runs` field to `Paragraph` in the exported `Comment` data type
- Add new exported function `AddFormControl` support to add button and radio form controls
- Add check for shape type for the `AddShape` function, an error will be returned if no shape type is specified
- Updated functions documentation and the unit tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
v2.8.0
Features
Development

No branches or pull requests

2 participants