2017-08-25 56 views
0

我有這個代碼使用openxml sdk生成PPT報表中的表。 此行是表格樣式的原因。在openxml中更改表格樣式文本爲powerpoint發電機

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

風格是:

enter image description here

我需要改變的樣式和顏色,但我無法找到任何東西。請幫忙。

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; 
    } 

鏈接前面的問題: create dynamic table in powerpoint using openXML with c# and ASP.net

unable to generate second table in PPT report using openxml

How to ignore/solve "Repair" message from Powerpoint report generated by OpenXML with ASP.net

回答

0

解決它。 所以我做的是,我手動創建了一個新的ppt>插入表,並將其保存爲ppt xml(您將在另存爲中看到此選項)。

打開xml搜索tablestyleid並在代碼中使用該值。