2020统计图表8296493207精品

上传人:精****库 文档编号:132339930 上传时间:2020-05-14 格式:DOC 页数:9 大小:117.61KB
返回 下载 相关 举报
2020统计图表8296493207精品_第1页
第1页 / 共9页
2020统计图表8296493207精品_第2页
第2页 / 共9页
2020统计图表8296493207精品_第3页
第3页 / 共9页
2020统计图表8296493207精品_第4页
第4页 / 共9页
2020统计图表8296493207精品_第5页
第5页 / 共9页
点击查看更多>>
资源描述

《2020统计图表8296493207精品》由会员分享,可在线阅读,更多相关《2020统计图表8296493207精品(9页珍藏版)》请在金锄头文库上搜索。

1、效果图:手把手教程:原理:OWC是Office Web Compent的缩写,即Microsoft的Office Web组件,它为在Web中绘制图形提供了灵活的同时也是最基本的机制。在一个intranet环境中,如果可以假设客户机上存在特定的浏览器和一些功能强大的软件(如IE6和Office 2000/XP/2003),那么就有能力利用Office Web组件提供一个交互式图形开发环境。这种模式下,客户端工作站将在整个任务中分担很大的比重。理论上说Excel能做的图都可以通过OWC画。第一步:右键点击网站根目录引用。如图所示:第二步:点击“添加引用”后弹出一个窗口,添加OWC的引用。如图所示:

2、点“确定”。第三步:代码中引用Microsoft.Office.Interop.Owc11。全部代码后台代码:using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.

3、SqlClient; /添加数据操作引用using Microsoft.Office.Interop.Owc11;/添加Office组件引用public partial class OWCdrawing : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) /连接数据库并获取特定字符串 string strSeriesName = 图例1; string ConnectString = Server=(local);DataBase=web;Uid=sa;Pwd=sa; string Sql = SE

4、LECT month,Allcount FROM Chart; SqlConnection myConn = new SqlConnection(ConnectString); myConn.Open(); SqlDataAdapter Da = new SqlDataAdapter(Sql, myConn); DataSet ds = new DataSet(); Da.Fill(ds);/存放月 string MonNum = new string12; /存放数据 string MonCount = new string12; /为数组赋值 for (int i = 0; i ds.Ta

5、bles0.Rows.Count; i+) MonNumi = ds.Tables0.Rowsi0.ToString(); MonCounti = ds.Tables0.Rowsi1.ToString(); /为x轴指定特定字符串,以便显示数据 string strXdata = String.Empty; foreach (string strData in MonNum) strXdata += strData + t; string strYdata = String.Empty; /为y轴指定特定的字符串,以便与x轴相对应 foreach (string strValue in Mon

6、Count) strYdata += strValue + t; /创建ChartSpace对象来放置图表 ChartSpace laySpace = new ChartSpaceClass(); /在ChartSpace对象中添加图表 ChChart InsertChart = laySpace.Charts.Add(0); /指定绘制图表的类型。类型可以通过OWC.ChartChartTypeEnum枚举值得到 /InsertChart.Type = ChartChartTypeEnum.chChartTypeLine;/折线图 /InsertChart.Type = ChartChart

7、TypeEnum.chChartTypeArea;/面积图 /InsertChart.Type = ChartChartTypeEnum.chChartTypeBarClustered;/条形图 InsertChart.Type = ChartChartTypeEnum.chChartTypeColumnClustered;/柱形图 /指定图表是否需要图例标注 InsertChart.HasLegend = false; InsertChart.HasTitle = true;/为图表添加标题 InsertChart.Title.Caption = 2006年清清月儿每个月花销流水账;/标题名

8、称 /为x,y轴添加图示说明 InsertChart.Axes0.HasTitle = true; InsertChart.Axes0.Title.Caption = ;/月份 InsertChart.Axes1.HasTitle = true; InsertChart.Axes1.Scaling.SplitMinimum = 200; InsertChart.Axes1.Title.Caption = 数量; /添加一个series系列 InsertChart.SeriesCollection.Add(0); /给定series系列的名字 InsertChart.SeriesCollecti

9、on0.SetData(ChartDimensionsEnum.chDimSeriesNames, +(int)ChartSpecialDataSourcesEnum.chDataLiteral, strSeriesName); /给定分类 InsertChart.SeriesCollection0.SetData(ChartDimensionsEnum.chDimCategories, +(int)ChartSpecialDataSourcesEnum.chDataLiteral, strXdata); /给定值 InsertChart.SeriesCollection0.SetData(C

10、hartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, strYdata); /输出文件. string strAbsolutePath = (Server.MapPath(.) + ShowData.gif; laySpace.ExportPicture(strAbsolutePath, GIF, 400, 250); /创建GIF文件的相对路径. string strRelativePath = ./ShowData.gif; /把图片添加到placeholder中,并在页面上显示 string strImageTag = ; this.PlaceHolder1.Controls.Add(new LiteralControl(strImageTag); 前台代码: 清清月儿http:/ 怎么样在ASP.NET2.0中使用OWC组件画图 数据库SQL脚本:USE webGO/* 对象: Table dbo.Chart 脚本日期: 03/27/2007 22:26:00 */SET A

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号