Пример #1
0
        TryGetMarkedColumnData
        (
            out Microsoft.Office.Interop.Excel.Range oMarkedColumnData
        )
        {
            AssertValid();

            Microsoft.Office.Interop.Excel.ListObject oVertexTable =
                Vertices.InnerObject;

            if (!ExcelUtil.TryGetTableColumnData(oVertexTable,
                                                 VertexTableColumnNames.Marked, out oMarkedColumnData))
            {
                Microsoft.Office.Interop.Excel.ListColumn oMarkedColumn;

                if (!ExcelUtil.TryAddTableColumn(oVertexTable,
                                                 VertexTableColumnNames.Marked,
                                                 ExcelUtil.AutoColumnWidth, null, out oMarkedColumn)
                    ||
                    !ExcelUtil.TryGetTableColumnData(oVertexTable,
                                                     VertexTableColumnNames.Marked, out oMarkedColumnData)
                    )
                {
                    return(false);
                }
            }

            return(true);
        }
        internal static void OpenLinkAsSheet(ExcelWorkbook workbook, String url)
        {
            string queryText = QueryTemplate.Replace("::URL::", url);

            //  add query
            dynamic workbook2 = workbook ?? CreateNewWorkbook();
            dynamic queries   = workbook2.Queries;
            dynamic query     = queries.Add("ODataQuery-" + DateTime.Now.ToString("yyyyMMddhhmmss"), queryText, "");

            // add sheet with query
            ExcelSheet sheet = workbook2.Sheets.Add();

            ExcelListObject listObject = sheet.ListObjects.Add(SourceType: 0, Source: "OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=" + query.Name, Destination: sheet.Range["$A$1"]);

            listObject.QueryTable.CommandType          = XlCmdType.xlCmdDefault;
            listObject.QueryTable.CommandText          = "SELECT * FROM [" + query.Name + "]";
            listObject.QueryTable.RowNumbers           = false;
            listObject.QueryTable.FillAdjacentFormulas = false;
            listObject.QueryTable.PreserveFormatting   = true;
            listObject.QueryTable.RefreshOnFileOpen    = false;
            listObject.QueryTable.BackgroundQuery      = true;
            listObject.QueryTable.RefreshStyle         = XlCellInsertionMode.xlOverwriteCells;
            listObject.QueryTable.SavePassword         = false;
            listObject.QueryTable.SaveData             = true;
            listObject.QueryTable.AdjustColumnWidth    = true;
            listObject.QueryTable.RefreshPeriod        = 0;
            listObject.QueryTable.PreserveColumnInfo   = false;

            listObject.QueryTable.Refresh(true);
        }
Пример #3
0
 GetTableColumnNames
 (
     Microsoft.Office.Interop.Excel.ListObject table
 )
 {
     return(ExcelTableUtil.GetTableColumnNames(table,
                                               TableColumnNamesToExclude, ExcelTableUtil.NoColumnNames));
 }
Пример #4
0
        GetTableColumnNamesInternal
        (
            Microsoft.Office.Interop.Excel.ListObject oTable
        )
        {
            AssertValid();

            return(GetTableColumnNames(oTable));
        }
Пример #5
0
        GetTableColumnNames
        (
            Microsoft.Office.Interop.Excel.ListObject oTable
        )
        {
            AssertValid();

            return(ExcelUtil.GetTableColumnNames(oTable,
                                                 TableColumnNamesToExclude, TableColumnNameBasesToExclude));
        }
Пример #6
0
        PopulateWithTableColumnNames
        (
            Microsoft.Office.Interop.Excel.ListObject table
        )
        {
            Debug.Assert(table != null);
            AssertValid();

            ComboBox.ObjectCollection oItems = this.Items;
            oItems.Clear();
            oItems.AddRange(GetTableColumnNamesInternal(table));
        }
Пример #7
0
        ThisWorkbook_AttributesEditedInGraph
        (
            Object sender,
            AttributesEditedEventArgs e
        )
        {
            Debug.Assert(e != null);
            AssertValid();

            // The key is the row ID stored in the table's ID column and the value
            // is the one-based row number relative to the worksheet.

            Dictionary <Int32, Int32> oRowIDDictionary;

            if (
                e.EditedEdgeAttributes == null
                ||
                !m_oSheets1And2Helper.TableExists
                ||
                !m_oSheets1And2Helper.TryGetAllRowIDs(out oRowIDDictionary)
                )
            {
                return;
            }

            Microsoft.Office.Interop.Excel.ListObject oEdgeTable =
                Edges.InnerObject;

            Globals.ThisWorkbook.ShowWaitCursor = true;

            // Get the columns that might need to be updated.  These columns are
            // not required.

            Microsoft.Office.Interop.Excel.Range oColorColumnData,
                                                 oWidthColumnData, oStyleColumnData, oAlphaColumnData,
                                                 oVisibilityColumnData, oLabelColumnData,
                                                 oLabelTextColorColumnData, oLabelFontSizeColumnData;

            Object [,] aoColorValues          = null;
            Object [,] aoWidthValues          = null;
            Object [,] aoStyleValues          = null;
            Object [,] aoAlphaValues          = null;
            Object [,] aoVisibilityValues     = null;
            Object [,] aoLabelValues          = null;
            Object [,] aoLabelTextColorValues = null;
            Object [,] aoLabelFontSizeValues  = null;

            ExcelTableUtil.TryGetTableColumnDataAndValues(oEdgeTable,
                                                          EdgeTableColumnNames.Color, out oColorColumnData,
                                                          out aoColorValues);

            ExcelTableUtil.TryGetTableColumnDataAndValues(oEdgeTable,
                                                          EdgeTableColumnNames.Width, out oWidthColumnData,
                                                          out aoWidthValues);

            ExcelTableUtil.TryGetTableColumnDataAndValues(oEdgeTable,
                                                          EdgeTableColumnNames.Style, out oStyleColumnData,
                                                          out aoStyleValues);

            ExcelTableUtil.TryGetTableColumnDataAndValues(oEdgeTable,
                                                          CommonTableColumnNames.Alpha, out oAlphaColumnData,
                                                          out aoAlphaValues);

            ExcelTableUtil.TryGetTableColumnDataAndValues(oEdgeTable,
                                                          CommonTableColumnNames.Visibility, out oVisibilityColumnData,
                                                          out aoVisibilityValues);

            ExcelTableUtil.TryGetTableColumnDataAndValues(oEdgeTable,
                                                          EdgeTableColumnNames.Label, out oLabelColumnData,
                                                          out aoLabelValues);

            ExcelTableUtil.TryGetTableColumnDataAndValues(oEdgeTable,
                                                          EdgeTableColumnNames.LabelTextColor, out oLabelTextColorColumnData,
                                                          out aoLabelTextColorValues);

            ExcelTableUtil.TryGetTableColumnDataAndValues(oEdgeTable,
                                                          EdgeTableColumnNames.LabelFontSize, out oLabelFontSizeColumnData,
                                                          out aoLabelFontSizeValues);

            ColorConverter2    oColorConverter2    = new ColorConverter2();
            EdgeStyleConverter oEdgeStyleConverter = new EdgeStyleConverter();

            EdgeVisibilityConverter oEdgeVisibilityConverter =
                new EdgeVisibilityConverter();

            // Loop through the IDs of the edges whose attributes were edited
            // in the graph.

            EditedEdgeAttributes oEditedEdgeAttributes = e.EditedEdgeAttributes;

            foreach (Int32 iID in e.EdgeIDs)
            {
                // Look for the row that contains the ID.

                Int32 iRowOneBased;

                if (!oRowIDDictionary.TryGetValue(iID, out iRowOneBased))
                {
                    continue;
                }

                iRowOneBased -= oEdgeTable.Range.Row;

                if (oEditedEdgeAttributes.Color.HasValue && aoColorValues != null)
                {
                    aoColorValues[iRowOneBased, 1] =
                        oColorConverter2.GraphToWorkbook(
                            oEditedEdgeAttributes.Color.Value);
                }

                if (oEditedEdgeAttributes.Width.HasValue && aoWidthValues != null)
                {
                    aoWidthValues[iRowOneBased, 1] =
                        oEditedEdgeAttributes.Width.Value.ToString();
                }

                if (oEditedEdgeAttributes.Style.HasValue && aoStyleValues != null)
                {
                    aoStyleValues[iRowOneBased, 1] =
                        oEdgeStyleConverter.GraphToWorkbook(
                            oEditedEdgeAttributes.Style.Value);
                }

                if (oEditedEdgeAttributes.Alpha.HasValue && aoAlphaValues != null)
                {
                    aoAlphaValues[iRowOneBased, 1] =
                        oEditedEdgeAttributes.Alpha.Value.ToString();
                }

                if (oEditedEdgeAttributes.Visibility.HasValue &&
                    aoVisibilityValues != null)
                {
                    aoVisibilityValues[iRowOneBased, 1] =
                        oEdgeVisibilityConverter.GraphToWorkbook(
                            oEditedEdgeAttributes.Visibility.Value);
                }

                if (!String.IsNullOrEmpty(oEditedEdgeAttributes.Label))
                {
                    aoLabelValues[iRowOneBased, 1] = oEditedEdgeAttributes.Label;
                }

                if (oEditedEdgeAttributes.LabelTextColor.HasValue &&
                    aoLabelTextColorValues != null)
                {
                    aoLabelTextColorValues[iRowOneBased, 1] =
                        oColorConverter2.GraphToWorkbook(
                            oEditedEdgeAttributes.LabelTextColor.Value);
                }

                if (oEditedEdgeAttributes.LabelFontSize.HasValue &&
                    aoLabelFontSizeValues != null)
                {
                    aoLabelFontSizeValues[iRowOneBased, 1] =
                        oEditedEdgeAttributes.LabelFontSize.Value.ToString();
                }
            }

            // Activate this worksheet first, because writing to an inactive
            // worksheet causes problems with the selection in Excel.

            ExcelActiveWorksheetRestorer oExcelActiveWorksheetRestorer =
                m_oSheets1And2Helper.GetExcelActiveWorksheetRestorer();

            ExcelActiveWorksheetState oExcelActiveWorksheetState =
                oExcelActiveWorksheetRestorer.ActivateWorksheet(this.InnerObject);

            try
            {
                m_oSheets1And2Helper.SetColumnDataValues(
                    oColorColumnData, aoColorValues,
                    oWidthColumnData, aoWidthValues,
                    oStyleColumnData, aoStyleValues,
                    oAlphaColumnData, aoAlphaValues,
                    oVisibilityColumnData, aoVisibilityValues,
                    oLabelColumnData, aoLabelValues,
                    oLabelTextColorColumnData, aoLabelTextColorValues,
                    oLabelFontSizeColumnData, aoLabelFontSizeValues
                    );
            }
            finally
            {
                oExcelActiveWorksheetRestorer.Restore(oExcelActiveWorksheetState);
            }

            Globals.ThisWorkbook.ShowWaitCursor = false;
        }
Пример #8
0
 GetTableColumnNamesInternal
 (
     Microsoft.Office.Interop.Excel.ListObject oTable
 );
Пример #9
0
        OnGraphLaidOut
        (
            GraphLaidOutEventArgs e
        )
        {
            Debug.Assert(e != null);
            AssertValid();

            // This method gathers some necessary information and returns without
            // doing anything else if some of the information is missing.

            Microsoft.Office.Interop.Excel.ListObject oVertexTable =
                Vertices.InnerObject;

            // Get the ID column data from the vertex table.  This excludes the
            // header.

            Microsoft.Office.Interop.Excel.Range oIDColumnData;

            if (!ExcelUtil.TryGetTableColumnData(oVertexTable,
                                                 CommonTableColumnNames.ID, out oIDColumnData))
            {
                return;
            }

            // Get the location columns from the vertex table.  These are the
            // entire table columns, including the headers.

            Microsoft.Office.Interop.Excel.ListColumn oXColumn, oYColumn;

            if (
                !ExcelUtil.TryGetTableColumn(oVertexTable,
                                             VertexTableColumnNames.X, out oXColumn)
                ||
                !ExcelUtil.TryGetTableColumn(oVertexTable,
                                             VertexTableColumnNames.Y, out oYColumn)
                )
            {
                return;
            }

            // The vertex table may be filtered.  Get the visible range, which may
            // contain multiple areas.

            Microsoft.Office.Interop.Excel.Range oDataBodyRange =
                Vertices.DataBodyRange;

            if (oDataBodyRange == null)
            {
                return;
            }

            Microsoft.Office.Interop.Excel.Range oVisibleDataBodyRange;

            if (!ExcelUtil.TryGetVisibleRange(oDataBodyRange,
                                              out oVisibleDataBodyRange))
            {
                return;
            }

            // The necessary information has been gathered.  Move on to the actual
            // work.  Activate this worksheet first, because writing to an inactive
            // worksheet causes problems with the selection in Excel.

            ExcelActiveWorksheetRestorer oExcelActiveWorksheetRestorer =
                GetExcelActiveWorksheetRestorer();

            ExcelActiveWorksheetState oExcelActiveWorksheetState =
                oExcelActiveWorksheetRestorer.ActivateWorksheet(this.InnerObject);

            try
            {
                OnGraphLaidOut(e, oVertexTable, oDataBodyRange,
                               oVisibleDataBodyRange, oIDColumnData, oXColumn, oYColumn);
            }
            finally
            {
                oExcelActiveWorksheetRestorer.Restore(oExcelActiveWorksheetState);
            }
        }
Пример #10
0
        OnVertexAttributesEditedInGraph
        (
            VertexAttributesEditedEventArgs e
        )
        {
            Debug.Assert(e != null);
            AssertValid();

            Microsoft.Office.Interop.Excel.ListObject oVertexTable =
                Vertices.InnerObject;

            // Get a dictionary containing the ID of each row in the table.

            Dictionary <Int32, Int32> oRowIDDictionary;

            if (!m_oSheets1And2Helper.TryGetAllRowIDs(out oRowIDDictionary))
            {
                // Nothing can be done without the IDs.

                return;
            }

            Globals.ThisWorkbook.ShowWaitCursor = true;

            // Get the columns that might need to be updated.  These columns are
            // not required.

            Microsoft.Office.Interop.Excel.Range oColorColumnData,
                                                 oShapeColumnData, oRadiusColumnData, oAlphaColumnData,
                                                 oVisibilityColumnData, oLabelPositionColumnData, oLockedColumnData,
                                                 oMarkedColumnData;

            Object [,] aoColorValues         = null;
            Object [,] aoShapeValues         = null;
            Object [,] aoRadiusValues        = null;
            Object [,] aoAlphaValues         = null;
            Object [,] aoVisibilityValues    = null;
            Object [,] aoLabelPositionValues = null;
            Object [,] aoLockedValues        = null;
            Object [,] aoMarkedValues        = null;

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
                                                     VertexTableColumnNames.Color, out oColorColumnData,
                                                     out aoColorValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
                                                     VertexTableColumnNames.Shape, out oShapeColumnData,
                                                     out aoShapeValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
                                                     VertexTableColumnNames.Radius, out oRadiusColumnData,
                                                     out aoRadiusValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
                                                     CommonTableColumnNames.Alpha, out oAlphaColumnData,
                                                     out aoAlphaValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
                                                     CommonTableColumnNames.Visibility, out oVisibilityColumnData,
                                                     out aoVisibilityValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
                                                     VertexTableColumnNames.LabelPosition, out oLabelPositionColumnData,
                                                     out aoLabelPositionValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
                                                     VertexTableColumnNames.Locked, out oLockedColumnData,
                                                     out aoLockedValues);

            if (TryGetMarkedColumnData(out oMarkedColumnData))
            {
                aoMarkedValues = ExcelUtil.GetRangeValues(oMarkedColumnData);
            }

            ColorConverter2 oColorConverter2 = new ColorConverter2();

            VertexShapeConverter oVertexShapeConverter =
                new VertexShapeConverter();

            VertexVisibilityConverter oVertexVisibilityConverter =
                new VertexVisibilityConverter();

            VertexLabelPositionConverter oVertexLabelPositionConverter =
                new VertexLabelPositionConverter();

            BooleanConverter oBooleanConverter = new BooleanConverter();

            // Loop through the IDs of the vertices whose attributes were edited
            // in the graph.

            EditedVertexAttributes oEditedVertexAttributes =
                e.EditedVertexAttributes;

            foreach (Int32 iID in e.VertexIDs)
            {
                // Look for the row that contains the ID.

                Int32 iRowOneBased;

                if (!oRowIDDictionary.TryGetValue(iID, out iRowOneBased))
                {
                    continue;
                }

                iRowOneBased -= oVertexTable.Range.Row;

                if (oEditedVertexAttributes.Color.HasValue &&
                    aoColorValues != null)
                {
                    aoColorValues[iRowOneBased, 1] =
                        oColorConverter2.GraphToWorkbook(
                            oEditedVertexAttributes.Color.Value);
                }

                if (oEditedVertexAttributes.Shape.HasValue &&
                    aoShapeValues != null)
                {
                    aoShapeValues[iRowOneBased, 1] =
                        oVertexShapeConverter.GraphToWorkbook(
                            oEditedVertexAttributes.Shape.Value);
                }

                if (oEditedVertexAttributes.Radius.HasValue &&
                    aoRadiusValues != null)
                {
                    aoRadiusValues[iRowOneBased, 1] =
                        oEditedVertexAttributes.Radius.Value.ToString();
                }

                if (oEditedVertexAttributes.Alpha.HasValue &&
                    aoAlphaValues != null)
                {
                    aoAlphaValues[iRowOneBased, 1] =
                        oEditedVertexAttributes.Alpha.Value.ToString();
                }

                if (oEditedVertexAttributes.Visibility.HasValue &&
                    aoVisibilityValues != null)
                {
                    aoVisibilityValues[iRowOneBased, 1] =
                        oVertexVisibilityConverter.GraphToWorkbook(
                            oEditedVertexAttributes.Visibility.Value);
                }

                if (oEditedVertexAttributes.LabelPosition.HasValue &&
                    aoLabelPositionValues != null)
                {
                    aoLabelPositionValues[iRowOneBased, 1] =
                        oVertexLabelPositionConverter.GraphToWorkbook(
                            oEditedVertexAttributes.LabelPosition.Value);
                }

                if (oEditedVertexAttributes.Locked.HasValue &&
                    aoLockedValues != null)
                {
                    aoLockedValues[iRowOneBased, 1] =
                        oBooleanConverter.GraphToWorkbook(
                            oEditedVertexAttributes.Locked.Value);
                }

                if (oEditedVertexAttributes.Marked.HasValue &&
                    aoMarkedValues != null)
                {
                    aoMarkedValues[iRowOneBased, 1] =
                        oBooleanConverter.GraphToWorkbook(
                            oEditedVertexAttributes.Marked.Value);
                }
            }

            // Activate this worksheet first, because writing to an inactive
            // worksheet causes problems with the selection in Excel.

            ExcelActiveWorksheetRestorer oExcelActiveWorksheetRestorer =
                GetExcelActiveWorksheetRestorer();

            ExcelActiveWorksheetState oExcelActiveWorksheetState =
                oExcelActiveWorksheetRestorer.ActivateWorksheet(this.InnerObject);

            try
            {
                if (aoColorValues != null)
                {
                    oColorColumnData.set_Value(Missing.Value, aoColorValues);
                }

                if (aoShapeValues != null)
                {
                    oShapeColumnData.set_Value(Missing.Value, aoShapeValues);
                }

                if (aoRadiusValues != null)
                {
                    oRadiusColumnData.set_Value(Missing.Value, aoRadiusValues);
                }

                if (aoAlphaValues != null)
                {
                    oAlphaColumnData.set_Value(Missing.Value, aoAlphaValues);
                }

                if (aoVisibilityValues != null)
                {
                    oVisibilityColumnData.set_Value(Missing.Value,
                                                    aoVisibilityValues);
                }

                if (aoLabelPositionValues != null)
                {
                    oLabelPositionColumnData.set_Value(Missing.Value,
                                                       aoLabelPositionValues);
                }

                if (aoLockedValues != null)
                {
                    oLockedColumnData.set_Value(Missing.Value, aoLockedValues);
                }

                if (aoMarkedValues != null)
                {
                    oMarkedColumnData.set_Value(Missing.Value, aoMarkedValues);
                }
            }
            finally
            {
                oExcelActiveWorksheetRestorer.Restore(oExcelActiveWorksheetState);
            }

            Globals.ThisWorkbook.ShowWaitCursor = false;
        }
Пример #11
0
        OnVerticesMoved
        (
            VerticesMovedEventArgs2 e
        )
        {
            Debug.Assert(e != null);
            AssertValid();

            Microsoft.Office.Interop.Excel.ListObject oVertexTable =
                Vertices.InnerObject;

            // Get a dictionary that maps IDs to row numbers, and get the location
            // columns from the vertex table.  These are the entire table columns,
            // including the headers.

            Dictionary <Int32, Int32> oRowIDDictionary;

            Microsoft.Office.Interop.Excel.ListColumn oXColumn, oYColumn;

            if (
                !m_oSheets1And2Helper.TryGetAllRowIDs(out oRowIDDictionary)
                ||
                !ExcelUtil.TryGetTableColumn(oVertexTable,
                                             VertexTableColumnNames.X, out oXColumn)
                ||
                !ExcelUtil.TryGetTableColumn(oVertexTable,
                                             VertexTableColumnNames.Y, out oYColumn)
                )
            {
                return;
            }

            // Create an object that converts a vertex location between coordinates
            // used in the NodeXL graph and coordinates used in the worksheet.

            VertexLocationConverter oVertexLocationConverter =
                new VertexLocationConverter(e.GraphRectangle);

            foreach (VertexAndRowID oVertexAndRowID in e.VerticesAndRowIDs)
            {
                // Look for the cell in the ID column that contains the specified
                // ID.

                Int32 iRowOneBased;

                if (!oRowIDDictionary.TryGetValue(oVertexAndRowID.VertexRowID,
                                                  out iRowOneBased))
                {
                    continue;
                }

                // Convert the vertex location to workbook coordinates.

                Single fWorkbookX, fWorkbookY;

                oVertexLocationConverter.GraphToWorkbook(
                    oVertexAndRowID.Vertex.Location, out fWorkbookX,
                    out fWorkbookY);

                // Update the X and Y cells.

                this.Cells[iRowOneBased, oXColumn.Range.Column] = fWorkbookX;
                this.Cells[iRowOneBased, oYColumn.Range.Column] = fWorkbookY;
            }
        }
Пример #12
0
        OnGraphLaidOut
        (
            GraphLaidOutEventArgs e,
            Microsoft.Office.Interop.Excel.ListObject oVertexTable,
            Microsoft.Office.Interop.Excel.Range oDataBodyRange,
            Microsoft.Office.Interop.Excel.Range oVisibleDataBodyRange,
            Microsoft.Office.Interop.Excel.Range oIDColumnData,
            Microsoft.Office.Interop.Excel.ListColumn oXColumn,
            Microsoft.Office.Interop.Excel.ListColumn oYColumn
        )
        {
            Debug.Assert(e != null);
            Debug.Assert(oVertexTable != null);
            Debug.Assert(oDataBodyRange != null);
            Debug.Assert(oVisibleDataBodyRange != null);
            Debug.Assert(oIDColumnData != null);
            Debug.Assert(oXColumn != null);
            Debug.Assert(oYColumn != null);
            AssertValid();

            // Read the ID column.

            Object [,] aoIDValues = ExcelUtil.GetRangeValues(oIDColumnData);

            // Read the lock column if it's available.  This excludes the header.
            // (Locked vertices should not have their locations changed.)

            Microsoft.Office.Interop.Excel.Range oLockedColumnData;
            Object [,] aoLockedValues = null;

            if (ExcelUtil.TryGetTableColumnData(oVertexTable,
                                                VertexTableColumnNames.Locked, out oLockedColumnData))
            {
                aoLockedValues = ExcelUtil.GetRangeValues(oLockedColumnData);
            }

            Int32 iDataBodyRangeRow = oDataBodyRange.Row;

            Int32 iXColumnOneBased = oXColumn.Range.Column;
            Int32 iYColumnOneBased = oYColumn.Range.Column;

            // Create an object that converts a vertex location between coordinates
            // used in the NodeXL graph and coordinates used in the worksheet.

            VertexLocationConverter oVertexLocationConverter =
                new VertexLocationConverter(e.GraphRectangle);

            // Loop through the areas in the visible range.

            foreach (Microsoft.Office.Interop.Excel.Range oVisibleDataArea in
                     oVisibleDataBodyRange.Areas)
            {
                // Get the row numbers for the ID and lock columns.  (These are
                // with respect to the ID and lock values.)

                Int32 iFirstIDRowOneBased =
                    oVisibleDataArea.Row - iDataBodyRangeRow + 1;

                Int32 iLastIDRowOneBased =
                    iFirstIDRowOneBased + oVisibleDataArea.Rows.Count - 1;

                Int32 iRows = iLastIDRowOneBased - iFirstIDRowOneBased + 1;

                // Get the row numbers for the location values within the visible
                // area.  (These are with respect to the worksheet.)

                Int32 iFirstXYRowOneBased = oVisibleDataArea.Row;
                Int32 iLastXYRowOneBased  = iFirstXYRowOneBased + iRows - 1;

                // Read the old location formulas within the visible area.  (To
                // avoid overwriting locked X,Y values that are formulas, read
                // formulas and not values.)

                Microsoft.Office.Interop.Excel.Range oXRange = this.get_Range(
                    this.Cells[iFirstXYRowOneBased, iXColumnOneBased],
                    this.Cells[iLastXYRowOneBased, iXColumnOneBased]
                    );

                Microsoft.Office.Interop.Excel.Range oYRange = this.get_Range(
                    this.Cells[iFirstXYRowOneBased, iYColumnOneBased],
                    this.Cells[iLastXYRowOneBased, iYColumnOneBased]
                    );

                Object [,] aoXFormulas = ExcelUtil.GetRangeFormulas(oXRange);
                Object [,] aoYFormulas = ExcelUtil.GetRangeFormulas(oYRange);

                for (Int32 iIDRowOneBased = iFirstIDRowOneBased;
                     iIDRowOneBased <= iLastIDRowOneBased; iIDRowOneBased++)
                {
                    if (aoLockedValues != null &&
                        VertexIsLocked(aoLockedValues, iIDRowOneBased))
                    {
                        // The old location shouldn't be changed.

                        continue;
                    }

                    // Get this row's ID.

                    Int32 iID;

                    if (!m_oSheets1And2Helper.TryGetRowID(
                            aoIDValues, iIDRowOneBased, out iID))
                    {
                        // The user may have added a row since the workbook was
                        // read into the graph.  Ignore this row.

                        continue;
                    }

                    // Get the vertex object corresponding to the ID.

                    IIdentityProvider oVertex;

                    if (!e.VertexIDDictionary.TryGetValue(iID, out oVertex))
                    {
                        continue;
                    }

                    // Convert the vertex location to workbook coordinates.

                    Single fWorkbookX, fWorkbookY;

                    Debug.Assert(oVertex is IVertex);

                    oVertexLocationConverter.GraphToWorkbook(
                        ((IVertex)oVertex).Location,
                        out fWorkbookX, out fWorkbookY);

                    // Store the vertex locations in the arrays.

                    Int32 iXYFormulasRowOneBased =
                        iIDRowOneBased - iFirstIDRowOneBased + 1;

                    aoXFormulas[iXYFormulasRowOneBased, 1] = fWorkbookX;
                    aoYFormulas[iXYFormulasRowOneBased, 1] = fWorkbookY;
                }

                // Set the new vertex locations in the worksheet.

                oXRange.Formula = aoXFormulas;
                oYRange.Formula = aoYFormulas;
            }
        }