diff --git a/vml.go b/vml.go index 7ea3e22..08d5498 100644 --- a/vml.go +++ b/vml.go @@ -372,7 +372,11 @@ func (f *File) commentsWriter() { // by given worksheet name and form control options. Supported form control // type: button, check box, group box, label, option button, scroll bar and // spinner. If set macro for the form control, the workbook extension should be -// XLSM or XLTM. Scroll value must be between 0 and 30000. +// XLSM or XLTM. Scroll value must be between 0 and 30000. Please note that if a +// cell link is set for a checkbox form control, Excelize will not assign a +// value to the linked cell when the checkbox is checked. To reflect the +// checkbox state, please use the 'SetCellValue' function to manually set the +// linked cell's value to true. // // Example 1, add button form control with macro, rich-text, custom button size, // print property on Sheet1!A2, and let the button do not move or size with @@ -826,6 +830,9 @@ func (f *File) addFormCtrlShape(preset formCtrlPreset, col, row int, anchor stri if (opts.Type == FormControlCheckBox || opts.Type == FormControlOptionButton) && opts.Checked { sp.ClientData.Checked = 1 } + if opts.FormControl.Type == FormControlCheckBox { + sp.ClientData.FmlaLink = opts.CellLink + } return &sp, sp.addFormCtrl(opts) } diff --git a/vml_test.go b/vml_test.go index dabd374..22b14f9 100644 --- a/vml_test.go +++ b/vml_test.go @@ -192,7 +192,7 @@ func TestFormControl(t *testing.T) { }, { Cell: "A6", Type: FormControlCheckBox, Text: "Check Box 2", - Format: GraphicOptions{Positioning: "twoCell"}, + CellLink: "C5", Format: GraphicOptions{Positioning: "twoCell"}, }, { Cell: "A7", Type: FormControlOptionButton, Text: "Option Button 1", Checked: true,