C# 如何在OpenXMLC.net中手动定义颜色代码?
我可以创建一个谷歌饼图,但导出到MS Word的地方只有默认的MS Word颜色。那么,如何以开放xml样式手动定义颜色代码呢?下面我添加了当触发导出按钮单击事件时的c代码C# 如何在OpenXMLC.net中手动定义颜色代码?,c#,asp.net,ms-word,openxml,C#,Asp.net,Ms Word,Openxml,我可以创建一个谷歌饼图,但导出到MS Word的地方只有默认的MS Word颜色。那么,如何以开放xml样式手动定义颜色代码呢?下面我添加了当触发导出按钮单击事件时的c代码 protected void btnExport_Click(object sender, EventArgs e) { CreateWordChart createWordChart = null; try { Random r = new Random();
protected void btnExport_Click(object sender, EventArgs e)
{
CreateWordChart createWordChart = null;
try
{
Random r = new Random();
string p = @"E:/File/Graph" + r.Next(1, 20000) + ".docx";
FileStream fs = File.Create(p);
fs.Close();
createWordChart = new CreateWordChart(p);
List<ChartSubArea> chartAreas = new List<ChartSubArea>();
SqlConnection conn = new SqlConnection("Data Source=10.0.0.101; uid=sa; pwd=sql;database=QuestionDB;");
DataSet ds = new DataSet();
DataTable dt = new DataTable();
conn.Open();
string cmdstr = "select top 5 First_name, COUNT(Department) [Department] from Employee group by First_name";
SqlCommand cmd = new SqlCommand(cmdstr, conn);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
adp.Fill(ds);
ds.Tables[0].Columns.Add("Column1", typeof(string));
System.Drawing.Color[] colorSet = new System.Drawing.Color[4] { System.Drawing.Color.Red, System.Drawing.Color.Blue, System.Drawing.Color.Green, System.Drawing.Color.Purple };
dt = ds.Tables[0];
string cat = "";
string val = "";
int i = 0;
foreach (DataRow dr in dt.Rows)
{
cat = dr[0].ToString();
val = dr[1].ToString();
chartAreas.Add(new ChartSubArea() { ColorDra = *colorSet*, Label = cat, Value = val });
i = i + 1;
}
createWordChart.CreateChart(chartAreas);
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (createWordChart != null)
{
createWordChart.Dispose();
}
}
}
public class ChartSubArea
{
public System.Drawing.Color[] ColorDra { get; set; }
public Shading purecolor { get; set; }
public SchemeColorValues Color { get; set; }
public String Label { get; set; }
public string Value { get; set; }
}
提前谢谢