Spreadsheet Document API, Spreadsheet Controls (Win and WPF) — Form Controls (v23.2)

Office-Inspired Products
22 February 2024

As you know, form controls represent interactive elements (buttons, checkboxes, and drop-down lists) and are used in worksheets to deliver a more refined user experience. In our last major release (v23.2), we implemented form control support in our Spreadsheet Document API library and our Spreadsheet UI Controls (for WinForms and WPF). As you can see in the following images, documents using form controls are now processed without content loss. You can also preview workbooks with content controls (in WinForms and WPF Spreadsheet Controls), print and export to PDF.

The Spreadsheet Form Control API subset allows you to manage form controls in code. You can add, edit, and remove the following form controls:

  • Button
  • Check box
  • Combo box
  • Group box
  • List box
  • Radio Button
  • Scrollbar
  • Spin Button

The following code snippet creates a list box and check box controls in the workbook, and saves the result to a PDF file:

using DevExpress.Spreadsheet;

Workbook workbook = new Workbook();

workbook.LoadDocument("Form Template.xlsx");

var formControls = workbook.Worksheets[0].FormControls;

// Create a list box:
var comboCellRange = workbook.Worksheets[0].Range["B4:C4"];
var comboBoxControl = formControls.AddComboBox(comboCellRange);
comboBoxControl.DropDownLines = 3;
comboBoxControl.SourceRange = workbook.Worksheets[0].Range["E2:E6"];
comboBoxControl.SelectedIndex = 1;

// Create a check box:
var checkRange = workbook.Worksheets[0].Range["D5:E5"];
var checkBoxControl = formControls.AddCheckBox(checkRange);
checkBoxControl.CheckState = FormControlCheckState.Checked;
checkBoxControl.PlainText = "Reviewed";

workbook.ExportToPdf("Simple Form.pdf");

Please refer to the following article for more code snippets and implementation details: Form Controls in Spreadsheet Documents

Note: In this release, our main goal was to limit content loss when an individual workbook (with forms) is processed using DevExpress components. At present, our form control implementation when using Spreadsheet UI Controls (WinForms and WPF) includes the following limitations:

  • No form control interactivity or related User Interface elements are available.
  • Form controls linked to a cell do not display associated values, and the linked cell does not change its value.
  • Cell values connected to form controls are not recalculated.

Your Feedback Matters

As always, your feedback is highly appreciated. Your responses to the following survey will help us fine-tune development strategies in future release cycles.

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.