Skip to main content
A newer version of this page is available. .

Use Spreadsheet Documents in Business Objects

  • 3 minutes to read

This topic describes how to customize the SpreadsheetPropertyEditor (Beta) and use it to display byte array properties in a WinForms application. The following image shows the Document.Text property displayed in this Property Editor:

Assign the SpreadsheetPropertyEditor to a Business Class’ Property

In Code

Decorate a business class’ property with the EditorAliasAttribute and pass the SpreadsheetPropertyEditor value as the attribute’s parameter:

using DevExpress.ExpressApp.Editors;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
// ...
private byte[] text;
[EditorAlias(EditorAliases.SpreadsheetPropertyEditor)] 
public byte[] Text { 
    get { return text; }
    set { SetPropertyValue(nameof(Text), ref text, value); }
}

In the Model Editor

Navigate to the Views | <DetailView> | Items | <PropertyEditor> node and set the PropertyEditorType property to DevExpress.ExpressApp.Office.Win.SpreadsheetPropertyEditor.

Customize the SpreadsheetPropertyEditor’s Behavior

Hide or Show the Formula Bar

The SpreadsheetPropertyEditor displays the Spreadsheet control with the Formula Bar, which allows end-users to view, enter, and edit formulas in cells.

Invoke the Model Editor for a WinForms module or application project, navigate to the Views | <DetailView> | Items | <PropertyEditor> node, and set the EnableFormulaBar property to false to hide the Formula Bar.

Hide or Show the Menu

The SpreadsheetPropertyEditor displays the Spreadsheet control with the Ribbon, Bars, or without a menu. To specify the Property Editor’s menu type, navigate to the Views | <DetailView> | Items | <PropertyEditor> node and specify the MenuManagerType property.

Customize the Menu

The default set of the SpreadsheetPropertyEditor‘s menu items does not include all available toolbars and ribbon pages (see the full list in the SpreadsheetToolbarType enumeration topic). Handle the SpreadsheetMenuManagerController.CustomizeSpreadsheetToolbarType event and use the static SpreadsheetPropertyEditor.DefaultSpreadsheetToolbarType property to specify toolbars and ribbon pages to be displayed:

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Office.Win;
using DevExpress.XtraSpreadsheet;
// ...
public class CustomSpreadsheetController : ViewController {
    protected override void OnActivated() {
        base.OnActivated();
        SpreadsheetMenuManagerController controller = Frame.GetController<SpreadsheetMenuManagerController>();
        if (controller != null) {
            controller.CustomizeSpreadsheetToolbarType += Controller_CustomizeSpreadsheetToolbarType;
        }
    }
    private void Controller_CustomizeSpreadsheetToolbarType(object sender, CustomizeSpreadsheetToolbarTypeEventArgs e) {
        SpreadsheetPropertyEditor.DefaultSpreadsheetToolbarType = SpreadsheetToolbarType.ChartTools | SpreadsheetToolbarType.TableTools;
    }
}

You can also customize the Bars menu at runtime. Your customizations are stored in the user’s model differences.

Edit the Document in a Separate Window

Use the Show in popup context menu command to open the document in a new modal window.