EPR类企业管理系统

在我们现有系统基础上或全新开发,提供定制服务
为您的企业高效快速实施ERP,WMS,MES,CRM管理系统
全面管控物料仓库、销售业务、采购业务、仓库业务
生产过程、质量检验、组织架构、业务报表


定制
QQ:460-3528

开发
QQ群:3360-90194

源码
微信:136-3650-3721

如何:访问电子表格编辑器控件

本主题描述如何使用Office模块访问和自定义XAF应用程序中的以下控件:

平台

控制

目的

WinForms

电子表格控件

用于显示电子表格文档

ASP.NET

ASPx电子表格

用于显示电子表格文档

ASP.NET

ASPxUploadControl

用于将电子表格文档上传到服务器

访问特定于WinForms的控件(SpreadsheetControl)

请按照以下步骤访问SpreadsheetControl,并限制工作表中可见行和列的数量。

  1. 在WinForms模块项目中创建一个自定义ViewController
  2. 在重写的OnActivated方法中,获取SpreadsheetServiceController并订阅其CustomizeSpreadsheetControl事件。
  3. CustomizeSpreadsheetControl的处理程序中,访问SpreadsheetControl并订阅其DocumentLoaded事件。
  4. DocumentLoaded事件处理程序中,使用SetSize方法指定活动工作表的可见行数和列数。

    using DevExpress.ExpressApp;
    using DevExpress.ExpressApp.Office.Win;
    using DevExpress.Spreadsheet;
    using DevExpress.XtraSpreadsheet;
    // ...
    public class WinSpreadsheetController : ViewController {
        protected override void OnActivated() {
            base.OnActivated();
            SpreadsheetServiceController controller = Frame.GetController<SpreadsheetServiceController>();
            if(controller != null) {
                controller.CustomizeSpreadsheetControl  = Controller_CustomizeSpreadsheetControl;
            }
        }
        private void Controller_CustomizeSpreadsheetControl(object sender, CustomizeSpreadsheetEventArgs e) {
            SpreadsheetControl spreadsheetControl = ((SpreadsheetPropertyEditor)sender).SpreadsheetControl;
            spreadsheetControl.DocumentLoaded  = SpreadsheetControl_DocumentLoaded;
        }
        private void SpreadsheetControl_DocumentLoaded(object sender, System.EventArgs e) {
            SpreadsheetControl spreadsheetControl = (SpreadsheetControl)sender;
            Worksheet worksheet = spreadsheetControl.ActiveWorksheet;
            spreadsheetControl.WorksheetDisplayArea.SetSize(worksheet.Index, 5, 10);
        }
    }
    

访问特定于ASP.NET的控件

访问ASPxSpreadsheet控件

请按照以下步骤访问ASPxSpreadsheet控件,并限制工作表中可见行和列的数量。

  1. 在ASP.NET模块项目中创建一个自定义ViewController
  2. 在重写的OnActivated方法中,处理ASPxSpreadsheetPropertyEditor.ControlCreated事件。
  3. 在事件处理程序中,使用SetSize方法指定可见行和列的数量。

    using System;
    using DevExpress.ExpressApp;
    using DevExpress.ExpressApp.Office.Web;
    using DevExpress.Web.ASPxSpreadsheet;
    // ...
    public class WebSpreadsheetController : ViewController<DetailView> {
        protected override void OnActivated() {
            base.OnActivated();
            foreach (ASPxSpreadsheetPropertyEditor editor in View.GetItems<ASPxSpreadsheetPropertyEditor>()) {
                if (editor.ASPxSpreadsheetControl != null) {
                    editor.ASPxSpreadsheetControl.Load  = SpreadsheetControl_Load;;
                }
                else {
                    editor.ControlCreated  = Editor_ControlCreated;
                }
            }
        }
        void Editor_ControlCreated(object sender, EventArgs e) {
            ASPxSpreadsheet spreadsheet = ((ASPxSpreadsheetPropertyEditor)sender).ASPxSpreadsheetControl;
            spreadsheet.Load  = SpreadsheetControl_Load;
        }
        void SpreadsheetControl_Load(object sender, EventArgs e) {
            ASPxSpreadsheet spreadsheetControl = (ASPxSpreadsheet)sender;
            spreadsheetControl.WorksheetDisplayArea.SetSize(0, 5, 10);
        }
    }
    

访问ASPxUploadControl

请按照以下步骤访问ASPxUploadControl并设置要在服务器上上传的文件的最大大小。

  1. 在ASP.NET模块项目中创建一个自定义ViewController
  2. 在重写的OnActivated方法中,处理ASPxSpreadsheetPropertyEditor.ControlCreated事件。
  3. 在事件处理程序中,使用MaxFileSize方法指定要在服务器上上传的文件的最大大小。
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Office.Web;
using DevExpress.Web;
using System;
// ...
public class WebSpreadsheetUploadController : ViewController<DetailView> {
    protected override void OnActivated() {
        base.OnActivated();
        foreach (ASPxSpreadsheetPropertyEditor editor in View.GetItems<ASPxSpreadsheetPropertyEditor>()) {
            if (editor.ASPxUploadControl != null) {
                CustomizeSpreadsheetUploadControl(editor.ASPxUploadControl);
            }
            else {
                editor.ControlCreated  = Editor_ControlCreated;
            }
        }
    }
    private void Editor_ControlCreated(object sender, EventArgs e) {
        ASPxUploadControl spreadsheetUploadControl = ((ASPxSpreadsheetPropertyEditor)sender).ASPxUploadControl;
        CustomizeSpreadsheetUploadControl(spreadsheetUploadControl);
    }
    private void CustomizeSpreadsheetUploadControl(ASPxUploadControl uploadControl) {
        uploadControl.ValidationSettings.MaxFileSize = 104857600;
    }
    protected override void OnDeactivated() {
        base.OnDeactivated();
        foreach (ASPxSpreadsheetPropertyEditor editor in View.GetItems<ASPxSpreadsheetPropertyEditor>()) {
            editor.ControlCreated -= Editor_ControlCreated;
        }
    }
}
相关文章

转载保留此链接,注明出处