Beispiel #1
0
        //*************************************************************************
        //  Method: ExportToNewMatrixWorkbook()
        //
        /// <summary>
        /// Exports the edge table to a new workbook as an adjacency matrix.
        /// </summary>
        //*************************************************************************
        public void ExportToNewMatrixWorkbook()
        {
            AssertValid();

            if (
            !this.ExcelApplicationIsReady(true)
            ||
            !MergeIsApproved(
                "add an Edge Weight column, and export the edges to a new"
                + " workbook as an adjacency matrix.")
            )
            {
            return;
            }

            ShowWaitCursor = true;

            this.ScreenUpdating = false;

            try
            {
            WorkbookExporter oWorkbookExporter =
                new WorkbookExporter(this.InnerObject);

            oWorkbookExporter.ExportToNewMatrixWorkbook();

            this.ScreenUpdating = true;
            }
            catch (ExportWorkbookException oExportWorkbookException)
            {
            this.ScreenUpdating = true;

            FormUtil.ShowWarning(oExportWorkbookException.Message);
            }
            catch (Exception oException)
            {
            this.ScreenUpdating = true;

            ErrorUtil.OnException(oException);
            }

            ShowWaitCursor = false;
        }
Beispiel #2
0
        //*************************************************************************
        //  Method: ExportSelectionToNewNodeXLWorkbook()
        //
        /// <summary>
        /// Exports the selected rows of the edge and vertex tables to a new NodeXL
        /// workbook.
        /// </summary>
        //*************************************************************************
        public void ExportSelectionToNewNodeXLWorkbook()
        {
            AssertValid();

            if ( !this.ExcelApplicationIsReady(true) )
            {
            return;
            }

            // Exporting the workbook changes the active worksheet several times.
            // Save the current active worksheet so it can be restored later.

            Object oOldActiveSheet = this.Application.ActiveSheet;

            this.ScreenUpdating = false;

            try
            {
            WorkbookExporter oWorkbookExporter =
                new WorkbookExporter(this.InnerObject);

            Workbook oNewWorkbook =
                oWorkbookExporter.ExportSelectionToNewNodeXLWorkbook();

            // Reactivate the original active worksheet.

            if (oOldActiveSheet is Worksheet)
            {
                ExcelUtil.ActivateWorksheet( (Worksheet)oOldActiveSheet );
            }

            // Activate the edge worksheet in the new workbook.

            // Note: When run in the debugger, activating the new workbook
            // causes a "System.Runtime.InteropServices.ExternalException
            // crossed a native/managed boundary" error.  There is no inner
            // exception.  This does not occur outside the debugger.  Does this
            // have something to do with Visual Studio security contexts?`

            ExcelUtil.ActivateWorkbook(oNewWorkbook);

            Worksheet oNewEdgeWorksheet;

            if ( ExcelUtil.TryGetWorksheet(oNewWorkbook, WorksheetNames.Edges,
                out oNewEdgeWorksheet) )
            {
                ExcelUtil.ActivateWorksheet(oNewEdgeWorksheet);
            }

            this.ScreenUpdating = true;
            }
            catch (ExportWorkbookException oExportWorkbookException)
            {
            this.ScreenUpdating = true;

            FormUtil.ShowWarning(oExportWorkbookException.Message);
            }
            catch (Exception oException)
            {
            this.ScreenUpdating = true;

            ErrorUtil.OnException(oException);
            }
        }