excel 知识备忘

   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 = 1; 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[0]), int.Parse(colorRgb[1]), int.Parse(colorRgb[2]));
            return System.Drawing.ColorTranslator.ToOle(c2);

        }

 

posted on 2019-12-17 10:41  GIS-MAN  阅读(246)  评论(0编辑  收藏  举报

导航