在powerxml生成器中更改openxml中的表样式文本 [英] change table style text in openxml for powerpoint generatron
问题描述
我使用openxml sdk编写了此代码,该代码在PPT报告中生成表格. 这是表格样式的原因.
I have this code using openxml sdk which generates table in PPT report. This line is the reason for table style.
tableStyleId.Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}";
样式是:
我需要更改样式和颜色,但是我找不到任何东西.请帮忙.
I need to change the style and colors but I couldn't find anything for that. Please help.
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;
}
链接到先前的问题: 使用以下方法在Powerpoint中创建动态表具有c#和ASP.net的openXML
Links to previous questions: create dynamic table in powerpoint using openXML with c# and ASP.net
如何忽略/解决修复" OpenXML使用ASP.net生成的Powerpoint报告中的错误消息
推荐答案
已解决. 所以我要做的是,创建了一个新的ppt>手动插入具有所需设计的表,然后将其另存为ppt xml(您将在另存为中看到此选项).
Solved it. So what I did was, I created a new ppt > inserted tables with required design manually in it and then saved it as ppt xml (you will see this option in save as).
打开该xml搜索tablestyleid,然后在代码中使用该值.
Open that xml search for tablestyleid and use that value in the code.
这篇关于在powerxml生成器中更改openxml中的表样式文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!