利用owc11生成的图片Owc11.ChartSpace如何保存在excel中
利用owc11动态生成的柱状图,如何让其它保存在EXCEL中,像利用excel的图片向导出成图片 --------------------编程问答-------------------- ChartSpace laySpace = new ChartSpaceClass();laySpace.Border.Color = "White";
laySpace.Interior.Color = "White";
laySpace.IsDirty = true;
//在ChartSpace对象中添加图表
ChChart InsertChart = laySpace.Charts.Add(0);
InsertChart.PlotArea.Border.Color = Microsoft.Office.Interop.Owc11.ChartColorIndexEnum.chColorNone;
InsertChart.PlotArea.Interior.Color = "white";//背景颜色设置为白色
InsertChart.Axes[1].HasMajorGridlines = false;//不显示横向网格线
//图表显示图例
InsertChart.HasLegend = true;
//InsertChart.Legend.Font.Size = 7;
//将图例放在图片下方
InsertChart.Legend.Position = ChartLegendPositionEnum.chLegendPositionBottom;
InsertChart.Legend.Border.Color = Microsoft.Office.Interop.Owc11.ChartColorIndexEnum.chColorNone;
//指定绘制图表的类型。类型可以通过OWC.ChartChartTypeEnum枚举值得到
InsertChart.Type = ChartChartTypeEnum.chChartTypePolarLine;//;chChartTypeLine;//折线图
//添加一个series系列
InsertChart.SeriesCollection.Add(0);
InsertChart.SeriesCollection[0].Line.Color =Color.Yellow;
//InsertChart.SeriesCollection[0].
InsertChart.SeriesCollection.Add(1);
InsertChart.SeriesCollection[1].Line.Color = Color.Blue;
ChBorder border = InsertChart.Border;
border.set_Weight(LineWeightEnum.owcLineWeightMedium);
//InsertChart.SeriesCollection[0].Line.Weight=Microsoft.Office.Interop.Owc11.LineWeightEnum.owcLineWeightHairline;
//InsertChart.SeriesCollection[0].Ungroup(true);
//InsertChart.SeriesCollection[1].Ungroup(true);
//ChAxis seAxes = InsertChart.Axes.Add(InsertChart.SeriesCollection[0].get_Scalings(ChartDimensionsEnum.chDimValues));
//seAxes.Position = ChartAxisPositionEnum.chAxisPositionRight;
//ChAxis seAxes1 = InsertChart.Axes.Add(InsertChart.SeriesCollection[1].get_Scalings(ChartDimensionsEnum.chDimValues));
//seAxes1.Position = ChartAxisPositionEnum.chAxisPositionRight;
//给定series系列的名字
InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimSeriesNames, +(int)ChartSpecialDataSourcesEnum.chDataLiteral, strSeriesName);
//给定分类
InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimCategories, +(int)ChartSpecialDataSourcesEnum.chDataLiteral, strXdata);
//给定值
InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, strYdata);
InsertChart.SeriesCollection[1].SetData(ChartDimensionsEnum.chDimSeriesNames, +(int)ChartSpecialDataSourcesEnum.chDataLiteral, strSeriesName1);
InsertChart.SeriesCollection[1].SetData(ChartDimensionsEnum.chDimCategories, +(int)ChartSpecialDataSourcesEnum.chDataLiteral, strXdata);
InsertChart.SeriesCollection[1].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, strZdata);
//控制X轴坐标显示
InsertChart.Axes[0].HasTickLabels = true;
InsertChart.Axes[0].TickLabelSpacing = 15;//没隔5个坐标显示一个X轴值
//InsertChart.Axes[0].Font.Size = 7;
//InsertChart.Axes[ChartAxisPositionEnum.chAxisPositionLeft].Scaling.Minimum = Convert.ToInt32(datatable3);
//InsertChart.Axes[ChartAxisPositionEnum.chAxisPositionLeft].Scaling.Maximum = Convert.ToInt32(datatable4);
//输出文件.
string chartImage = path + "\\HK" + StockCode + ".jpg";
laySpace.ExportPicture(chartImage, "jpg", 450, 350);
补充:.NET技术 , ASP.NET