Skip to content

Commit f85dae6

Browse files
committed
This closes qax-os#2113, AddFormControl function support set cell link for check box
1 parent 6007d25 commit f85dae6

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Diff for: vml.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,11 @@ func (f *File) commentsWriter() {
372372
// by given worksheet name and form control options. Supported form control
373373
// type: button, check box, group box, label, option button, scroll bar and
374374
// spinner. If set macro for the form control, the workbook extension should be
375-
// XLSM or XLTM. Scroll value must be between 0 and 30000.
375+
// XLSM or XLTM. Scroll value must be between 0 and 30000. Please note that if a
376+
// cell link is set for a checkbox form control, Excelize will not assign a
377+
// value to the linked cell when the checkbox is checked. To reflect the
378+
// checkbox state, please use the 'SetCellValue' function to manually set the
379+
// linked cell's value to true.
376380
//
377381
// Example 1, add button form control with macro, rich-text, custom button size,
378382
// 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
826830
if (opts.Type == FormControlCheckBox || opts.Type == FormControlOptionButton) && opts.Checked {
827831
sp.ClientData.Checked = 1
828832
}
833+
if opts.FormControl.Type == FormControlCheckBox {
834+
sp.ClientData.FmlaLink = opts.CellLink
835+
}
829836
return &sp, sp.addFormCtrl(opts)
830837
}
831838

Diff for: vml_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func TestFormControl(t *testing.T) {
192192
},
193193
{
194194
Cell: "A6", Type: FormControlCheckBox, Text: "Check Box 2",
195-
Format: GraphicOptions{Positioning: "twoCell"},
195+
CellLink: "C5", Format: GraphicOptions{Positioning: "twoCell"},
196196
},
197197
{
198198
Cell: "A7", Type: FormControlOptionButton, Text: "Option Button 1", Checked: true,

0 commit comments

Comments
 (0)