如何使用图表控件开发仪表板 [英] How to develop dashboard with chart controls

查看:91
本文介绍了如何使用图表控件开发仪表板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是刚开始在.NET中开发仪表板应用程序的人.谁能指导我如何使用Excel工作表中的数据开发报表应用程序(Dundas仪表板示例).

以下是我用于后面代码的代码:

Hi,

I''m new to develop dashboard application in .NET. Can anyone guide me in how to develop an application for reports using data from an Excel sheet (dundas dashboard samples).

Below is the code I used for code behind:

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Web.UI.DataVisualization.Charting;
using System.Data.OleDb;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // resolve the address to the Excel file
    string fileNameString = Server.MapPath(".") +@"\data\ExcelData.xls";

    // Create connection object by using the preceding connection string.
    string sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +  fileNameString + ";Extended Properties=\"Excel 8.0;HDR=YES\"";
    OleDbConnection myConnection = new OleDbConnection( sConn );
    myConnection.Open();

    // The code to follow uses a SQL SELECT command to display the data from the worksheet.
    // Create new OleDbCommand to return data from worksheet.
    OleDbCommand myCommand = new OleDbCommand( "Select * From [data1$A1:E25]", myConnection );

    // create a database reader    
    OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

    // Populate the chart with data in the file
    Chart1.DataBindTable(myReader, "HOUR");

    // close the reader and the connection
    myReader.Close();
    myConnection.Close();
    }
}



还有其他方法或代码示例吗?
请指导我!



Is there any other way or a code example to follow?
Please guide me!

推荐答案

A1:E25]",myConnection); // 创建数据库读取器 OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection); // 用文件中的数据填充图表 Chart1.DataBindTable(myReader," ); // 关闭阅读器和连接 myReader.Close(); myConnection.Close(); } }
A1:E25]", myConnection ); // create a database reader OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection); // Populate the chart with data in the file Chart1.DataBindTable(myReader, "HOUR"); // close the reader and the connection myReader.Close(); myConnection.Close(); } }



还有其他方法或代码示例吗?
请引导我!



Is there any other way or a code example to follow?
Please guide me!


这篇关于如何使用图表控件开发仪表板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆