EPPlus
EPPlus 5.5 supports adding, modifying and removing nine different types of form controls.
Supported form controls are:
Buttons
Drop-Downs
List Boxes
Check Boxes
Radio Buttons
Spin Buttons
Scroll Bars
Labels
Group Boxes
Form controls are added via the worksheets forms collection using the AddControl method or it's typed variant.
Here we add a button and connect it to a vba macro:
var button = formSheet.Drawings.AddButtonControl("ExportButton");
button.Text = "Make Reservation";
button.Macro = "ExportButton_Click";
button.SetPosition(15, 0, 1, 0);
button.AutomaticSize = true;
Drawings can also be grouped/ungrouped using the new Group and Ungroup method available on all drawings
//Add a group box and four option boxes to select room type
var grpBox = formSheet.Drawings.AddGroupBoxControl("GroupBox 1");
grpBox.Text = "Room types";
grpBox.SetPosition(5, 8, 1, 1);
grpBox.SetSize(150, 80);
var r1 = formSheet.Drawings.AddRadioButtonControl("OptionSingleRoom");
r1.Text = "Single Room";
r1.FirstButton = true;
r1.LinkedCell = formSheet.Cells["C7"];
r1.SetPosition(5, 15, 1, 5);
var r2 = formSheet.Drawings.AddRadioButtonControl("OptionDoubleRoom");
r2.Text = "Double Room";
r2.LinkedCell = formSheet.Cells["C7"];
r2.SetPosition(6, 15, 1, 5);
r2.Checked = true;
//This will group the groupbox and the radio buttons together as one unit.
var grp = grpBox.Group(r1, r2);
Check out
this wiki article
or sample 26 for more details.
.NET Core
,
.NET Framework