WinForms and WPF Spreadsheet: Data Validation, Page Setup and more (Coming soon in v15.1)

Thinking Out Loud
03 June 2015

Yesterday I discussed the improved Copy/paste functionality  in our Spreadsheet control. In this post, I'll discuss a few other important features we'll introduce for our WinForms and WPF Spreadsheet Control.

Data Validation Support

Use it to prevent invalid data entry into worksheet cells. Here are a few things you'll be able to do with this new feature:

  • Create a drop-down list of predefined values
  • Restrict numbers outside a specified range
  • Restrict dates and times outside a certain time interval
  • Limit the number of characters entered into a cell
  • Validate data using a comprehensive set of spreadsheet formulas

Data validation settings are located in the Data Tools group of the Data tab.

WinForms and WPF Spreadsheet - Data Validation

End-users can apply data validation rules to cells using the Data Validation dialog. The dialog allows them to specify data validation criteria, add a descriptive message to validated cells and create an error alert to be displayed when a user enters invalid data.

WinForms and WPF Spreadsheet - Data Validation Dialog

To specify data validation in code, use the Worksheet.DataValidations property. This provides access to a collection of DataValidation objects, combining the validated cell range, validation rule type and validation parameters required by a rule. For example, you can use the following code to create a data validation rule that invokes a custom error message when a user enters a number less than 5-digits.

// Restrict data entry to a 5-digit number.
DataValidation validation = worksheet.DataValidations.Add(worksheet["B3:B10"], DataValidationType.Custom, "=AND(ISNUMBER(B3),LEN(B3)=5)");
 
// Setup the error message.
validation.ErrorTitle = "Invalid Employee Id";
validation.ErrorMessage = "The value you entered is not valid. Use a 5-digit number for the employee id.";
validation.ShowErrorMessage = true;

Page Setup

In addition to the commands located in the Page Layout ribbon page group, this release incorporates a new Page Setup dialog. Use this dialog to specify printing settings for a worksheet (set page orientation, paper size, page margins, printout and scaling options, etc).

WinForms and WPF Spreadsheet - Page Setup Dialog
 
Headers and Footers

With v15.1, you can now insert headers and footers at the top and bottom of a worksheet printout. To get started, invoke the Page Setup dialog and switch to the Header/Footer tab. Select one of the predefined options in the Header or Footer drop-down list, or click the Custom Header/Footer... button to add your custom header/footer.
 
The Spreadsheet control also supports header/footer codes so you can insert dynamic information, such as page numbers, current date and time, filename, worksheet name, etc.

WinForms and WPF Spreadsheet - Custome Header & Footer
 
To view worksheet headers and footers, invoke the Print Preview window, or export the document to PDF format.

WinForms and WPF Spreadsheet - Print Preview
 
As always, we welcome your comments and feedback. Let us know what you think of these new features.

FREE DevExpress Xamarin UI Controls

Deliver high-impact native mobile apps with our feature-rich Data Grid, Scheduler, Chart, TabView, Editors, and utility controls. Reserve your free copy today!
No Comments

Please login or register to post comments.