簡體   English   中英

在powerxml生成器中更改openxml中的表格樣式文本

[英]change table style text in openxml for powerpoint generatron

我有使用openxml sdk的代碼,該代碼在PPT報告中生成表。 這行是表格樣式的原因。

  tableStyleId.Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}";

風格是:

在此處輸入圖片說明

我需要更改樣式和顏色,但是我找不到任何東西。 請幫忙。

private D.Table GenerateTable(int projectID, string reportType)
    {
        // Declare and instantiate table  
        D.Table table = new D.Table();

        // Specify the required table properties for the table 
        D.TableProperties tableProperties = new D.TableProperties() { FirstRow = true, BandRow = false };
        D.TableStyleId tableStyleId = new D.TableStyleId();
        tableStyleId.Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}";

        tableProperties.Append(tableStyleId);
        D.TableGrid tableGrid1 = new D.TableGrid();
        System.Data.DataTable dtData = new System.Data.DataTable();
        if (reportType == "projcharter")
        {
            //tblXBenefit
            dtData = GetBenefit(projectID);

            // Declare and instantiate tablegrid and colums 
            //D.TableGrid tableGrid1 = new D.TableGrid();
            D.GridColumn gridColumn1 = new D.GridColumn() { Width = 1848000L };
            D.GridColumn gridColumn2 = new D.GridColumn() { Width = 648000L };
            D.GridColumn gridColumn3 = new D.GridColumn() { Width = 648000L };
            D.GridColumn gridColumn4 = new D.GridColumn() { Width = 648000L };

            tableGrid1.Append(gridColumn1);
            tableGrid1.Append(gridColumn2);
            tableGrid1.Append(gridColumn3);
            tableGrid1.Append(gridColumn4);
        }
        table.Append(tableProperties);
        table.Append(tableGrid1);

        // Instantiate the table header row 
        D.TableRow tableHRow = new D.TableRow() { Height = 0L };
        for (int column = 0; column < dtData.Columns.Count; column++)
        {
            tableHRow.Append(CreateTextCell(dtData.Columns[column].ToString()));
        }
        table.Append(tableHRow);

        // Instantiate the table data row 
        for (int row = 0; row < dtData.Rows.Count; row++)
        {
            // Instantiate the table row 
            D.TableRow tableRow = new D.TableRow() { Height = 0L };
            for (int column = 0; column < dtData.Columns.Count; column++)
            {
                tableRow.Append(CreateTextCell(dtData.Rows[row][column].ToString()));
            }
            table.Append(tableRow);
        }
        return table;
    }

鏈接到先前的問題: 使用帶有c#和ASP.net的openXML在Powerpoint中創建動態表

無法使用openxml在PPT報告中生成第二張表

如何忽略/解決由OpenXML使用ASP.net生成的Powerpoint報告中的“修復”消息

解決了。 所以我要做的是,創建了一個新的ppt>手動插入具有所需設計的表,然后將其另存為ppt xml(您將在另存為中看到此選項)。

打開該xml搜索tablestyleid,然后在代碼中使用該值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM