您好,
我是新发展的仪表板。NET应用程序。任何人都可以指导我如何开发一个应用程序使用一个Excel工作表中的数据报告(登打士仪表板样品)。
下面是我的代码使用后面的代码:
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();
}
}
有其他任何方式或代码榜样?
请指导我!