static public void SetChartDataColor(string chartName, object[,] datas, Excel.ChartObjects chObjs, int colIdx) { foreach (Excel.ChartObject chObj in chObjs) { if (chObj.Name.Equals(chartName)) { Excel.Series oSeries = chObj.Chart.SeriesCollection(1); for (int i = 1; i <= datas.GetLength(0); i++) { object oVal = datas.GetValue(i, colIdx); double val = Convert.ToDouble(oVal); Excel.Point oPoint = oSeries.Points(i); if (val >= 1) { oPoint.Format.Fill.ForeColor.RGB = 0x0000FF; } else if ((val < 1) && (val >= 0.5)) { oPoint.Format.Fill.ForeColor.RGB = 0xCC99FF; } } return; } } }
public void Rolling(DateTime dateThisDay) { object lockobject = new object(); lock (lockobject) { UInt16 RegionsCount = this.F_Regions.Count; if (RegionsCount > 0) { this.Application.ScreenUpdating = false; //禁用excel界面 Series series_Depth = this.F_Series_Depth; clsData_ProcessRegionData Region = default(clsData_ProcessRegionData); Microsoft.Office.Interop.Excel.Point Pt = default(Microsoft.Office.Interop.Excel.Point); float[] Depths = new float[RegionsCount - 1 + 1]; for (UInt16 i = 0; i <= RegionsCount - 1; i++) { Region = this.F_Regions.Item(i); Pt = series_Depth.Points().item(i + 1); if (Region.HasBottomDate) { if (dateThisDay.CompareTo(Region.BottomDate) > 0) //说明已经开挖到基坑底,并在向上进行结构物的施工 { Pt.Format.Fill.ForeColor.RGB = Information.RGB(255, 0, 0); } else //说明还未开挖到基坑底,并在向下开挖 { Pt.Format.Fill.ForeColor.RGB = Information.RGB(0, 0, 255); } } try { Depths[i] = System.Convert.ToSingle(Region.Date_Elevation[dateThisDay]); } catch (KeyNotFoundException) { DateTime ClosestDate = ClsData_DataBase.FindTheClosestDateInSortedList(Region.Date_Elevation.Keys, dateThisDay); Depths[i] = System.Convert.ToSingle(Region.Date_Elevation[ClosestDate]); } } series_Depth.Values = Depths; //刷新日期放置在最后,以免由于耗时过长而出现误判 this.F_textbox_Info.TextRange.Text = dateThisDay.ToString(AMEApplication.DateFormat); } this.Application.ScreenUpdating = true; //刷新excel界面 } }