public static void InitializeSpreadsheet(this SpreadsheetControl spreadsheetControl)
        {
            SpreadsheetUtils.InitializeWorkbook(spreadsheetControl.Document);
            spreadsheetControl.Options.Behavior.FunctionNameCulture = FunctionNameCulture.English;

            spreadsheetControl.DocumentLoaded += (s, e) =>
                                                 SpreadsheetUtils.InitializeWorkbook(((SpreadsheetControl)s).Document);

            spreadsheetControl.EmptyDocumentCreated += (s, e) =>
                                                       SpreadsheetUtils.InitializeWorkbook(((SpreadsheetControl)s).Document);

            spreadsheetControl.CellBeginEdit    += SpreadRichTextEditForm.SpreadsheetControl_CellBeginEdit;
            spreadsheetControl.PopupMenuShowing += SpreadRichTextEditForm.SpreadsheetControl_PopupMenuShowing;

            spreadsheetControl.KeyDown += SpreadsheetControl_KeyDown;

            spreadsheetControl.BeforeDragRange += SpreadsheetControl_BeforeDragRange;
            spreadsheetControl.DragOver        += SpreadsheetControl_DragOver;
            spreadsheetControl.DragDrop        += SpreadsheetControl_DragDrop;

            var oldMouseHandler = (IMouseHandlerService)spreadsheetControl.GetService(typeof(IMouseHandlerService));

            if (oldMouseHandler != null)
            {
                spreadsheetControl.RemoveService(typeof(IMouseHandlerService));
            }
            var newMouseHandler = new SCMouseHandlerService(spreadsheetControl, oldMouseHandler);

            spreadsheetControl.AddService(typeof(IMouseHandlerService), newMouseHandler);
        }
Exemplo n.º 2
0
        // add a "MS Access File" option into a standard Open File dialog
        public static void ExtendOpenFileCommand(this SpreadsheetControl spreadSheet)
        {
            IDocumentImportManagerService      service       = (IDocumentImportManagerService)spreadSheet.GetService(typeof(IDocumentImportManagerService));
            CustomDocumentImportManagerService customService = new CustomDocumentImportManagerService(spreadSheet.Document);

            spreadSheet.ReplaceService <IDocumentImportManagerService>(customService);
        }
Exemplo n.º 3
0
        private void Sp_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e)
        {
            SpreadsheetControl control = sender as SpreadsheetControl;

            if (e.MenuType == SpreadsheetMenuType.Cell)
            {
                e.Menu.RemoveMenuItem(SpreadsheetCommandId.InsertHyperlinkContextMenuItem);
                ISpreadsheetCommandFactoryService service = (ISpreadsheetCommandFactoryService)control.GetService(typeof(ISpreadsheetCommandFactoryService));

                //SpreadsheetMenuItemCommandWinAdapter adapter = new SpreadsheetMenuItemCommandWinAdapter(service.CreateCommand(SpreadsheetCommandId.FileNew));
                //SpreadsheetMenuItem item = (SpreadsheetMenuItem)adapter.CreateMenuItem(DXMenuItemPriority.Normal);
                //item.BeginGroup = true;
                //item.Caption = "新建";
                //e.Menu.Items.Add(item);

                //SpreadsheetMenuItemCommandWinAdapter adapter2 = new SpreadsheetMenuItemCommandWinAdapter(service.CreateCommand(SpreadsheetCommandId.FileOpen));
                //var item2 = (SpreadsheetMenuItem)adapter2.CreateMenuItem(DXMenuItemPriority.Normal);
                //item2.Caption = "打开Excel文件";
                //e.Menu.Items.Add(item2);

                SpreadsheetMenuItemCommandWinAdapter adapter3 = new SpreadsheetMenuItemCommandWinAdapter(service.CreateCommand(SpreadsheetCommandId.FileSaveAs));
                var item3 = (SpreadsheetMenuItem)adapter3.CreateMenuItem(DXMenuItemPriority.Normal);
                item3.Caption = "另存为";
                e.Menu.Items.Add(item3);

                SpreadsheetMenuItemCommandWinAdapter adapter4 = new SpreadsheetMenuItemCommandWinAdapter(service.CreateCommand(SpreadsheetCommandId.FilePrintPreview));
                var item4 = (SpreadsheetMenuItem)adapter4.CreateMenuItem(DXMenuItemPriority.Normal);
                item4.Caption = "打印预览";
                e.Menu.Items.Add(item4);

                SpreadsheetMenuItemCommandWinAdapter adapter5 = new SpreadsheetMenuItemCommandWinAdapter(service.CreateCommand(SpreadsheetCommandId.ViewShowGridlines));
                var item5 = (SpreadsheetMenuItem)adapter5.CreateMenuItem(DXMenuItemPriority.Normal);
                item5.Caption = "显示/隐藏网格线";
                e.Menu.Items.Add(item5);

                SpreadsheetMenuItemCommandWinAdapter adapter6 = new SpreadsheetMenuItemCommandWinAdapter(service.CreateCommand(SpreadsheetCommandId.ViewShowHeadings));
                var item6 = (SpreadsheetMenuItem)adapter6.CreateMenuItem(DXMenuItemPriority.Normal);
                item6.Caption = "显示/隐藏excel列头";
                e.Menu.Items.Add(item6);
            }
        }