excel 知识备忘

时间:2021-06-19 15:44:43
   public void UpdateShapesColor(string value)
{
foreach (Microsoft.Office.Interop.Excel.Shape chart in GeneratedShapesArray)
{
// StyleHelper.SetChartTableColor(chart.Chart, value);
chart.BackgroundStyle = MsoBackgroundStyleIndex.msoBackgroundStylePreset11;
Microsoft.Office.Interop.Excel.SeriesCollection sc = chart.Chart.SeriesCollection();
int count= sc.Count;
for (int i = ; i <=count; i++)
{
Series series = chart.Chart.SeriesCollection(i);
//siries.Format.Line.ForeColor =
series.Border.Color = (int)XlRgbColor.rgbDarkSeaGreen;
} }
}

另一种填充图表线颜色的方法

private static void SetSeriesColor(Microsoft.Office.Interop.Excel.Point serie, int RGB)
{
Microsoft.Office.Interop.Excel.FillFormat ff = serie.Format.Fill;
ff.Visible = MsoTriState.msoCTrue;
ff.ForeColor.RGB = RGB;
ff.Transparency = 0;
ff.Solid();
}

  

 private static int GetColorIntRGB(string rgb)
{
if (rgb == "" || rgb == null)
rgb = "255,255,255"; var colorRgb = rgb.Split(',');
System.Drawing.Color c2 = System.Drawing.Color.FromArgb(int.Parse(colorRgb[]), int.Parse(colorRgb[]), int.Parse(colorRgb[]));
return System.Drawing.ColorTranslator.ToOle(c2); }