Smrf.NodeXL.ExcelTemplate.NodeXLWorkbookUtil.ClearAllNodeXLTables C# (CSharp) Method

ClearAllNodeXLTables() public static method

public static ClearAllNodeXLTables ( Microsoft workbook ) : void
workbook Microsoft
return void
    ClearAllNodeXLTables
    (
        Microsoft.Office.Interop.Excel.Workbook workbook
    )
    {
        Debug.Assert(workbook != null);

        TableImagePopulator.DeleteImagesInColumn(workbook,
            WorksheetNames.Vertices, VertexTableColumnNames.SubgraphImage);

        ExcelTableUtil.ClearTables(workbook,
            WorksheetNames.Edges, TableNames.Edges,
            WorksheetNames.Vertices, TableNames.Vertices,
            WorksheetNames.OverallMetrics, TableNames.OverallMetrics,
            WorksheetNames.OverallMetrics, TableNames.OverallReadabilityMetrics,
            WorksheetNames.Miscellaneous, TableNames.DynamicFilterSettings
            );

        ClearGroupTables(workbook);

        foreach (String sWorksheetName in new String [] {
            WorksheetNames.TopNByMetrics,
            WorksheetNames.TwitterSearchNetworkTopItems,
            WorksheetNames.WordCounts,
            WorksheetNames.WordPairCounts,
            } )
        {
            ExcelUtil.TryClearWorksheet(workbook, sWorksheetName);
        }

        ( new PerWorkbookSettings(workbook) ).OnWorkbookTablesCleared();
    }

Usage Example

Ejemplo n.º 1
0
        ImportGraph
        (
            IGraph sourceGraph,
            String [] edgeAttributes,
            String [] vertexAttributes,
            Boolean clearTablesFirst,
            Microsoft.Office.Interop.Excel.Workbook destinationNodeXLWorkbook
        )
        {
            Debug.Assert(sourceGraph != null);
            Debug.Assert(destinationNodeXLWorkbook != null);

            if (clearTablesFirst)
            {
                NodeXLWorkbookUtil.ClearAllNodeXLTables(destinationNodeXLWorkbook);
            }

            // Get the required table that contains edge data.  GetEdgeTable()
            // throws an exception if the table is missing.

            EdgeWorksheetReader oEdgeWorksheetReader = new EdgeWorksheetReader();

            ListObject oEdgeTable =
                oEdgeWorksheetReader.GetEdgeTable(destinationNodeXLWorkbook);

            // Get the required columns.

            Range oVertex1NameColumnData = null;
            Range oVertex2NameColumnData = null;

            if (
                !ExcelTableUtil.TryGetTableColumnData(oEdgeTable,
                                                      EdgeTableColumnNames.Vertex1Name, out oVertex1NameColumnData)
                ||
                !ExcelTableUtil.TryGetTableColumnData(oEdgeTable,
                                                      EdgeTableColumnNames.Vertex2Name, out oVertex2NameColumnData)
                )
            {
                ErrorUtil.OnMissingColumn();
            }

            // Import the edges and their attributes into the workbook.

            ImportEdges(sourceGraph, edgeAttributes, oEdgeTable,
                        oVertex1NameColumnData, oVertex2NameColumnData, !clearTablesFirst);

            // Populate the vertex worksheet with the name of each unique vertex in
            // the edge worksheet.

            (new VertexWorksheetPopulator()).PopulateVertexWorksheet(
                destinationNodeXLWorkbook, false);

            // Get the table that contains vertex data.

            ListObject oVertexTable;
            Range      oVertexNameColumnData = null;
            Range      oVisibilityColumnData = null;

            if (
                !ExcelTableUtil.TryGetTable(destinationNodeXLWorkbook,
                                            WorksheetNames.Vertices, TableNames.Vertices, out oVertexTable)
                ||
                !ExcelTableUtil.TryGetTableColumnData(oVertexTable,
                                                      VertexTableColumnNames.VertexName, out oVertexNameColumnData)
                ||
                !ExcelTableUtil.TryGetTableColumnData(oVertexTable,
                                                      CommonTableColumnNames.Visibility, out oVisibilityColumnData)
                )
            {
                ErrorUtil.OnMissingColumn();
            }

            // Import isolated vertices and the attributes for all the graph's
            // vertices.

            ImportVertices(sourceGraph, vertexAttributes, oVertexTable,
                           oVertexNameColumnData, oVisibilityColumnData);
        }