Click here to Skip to main content
15,894,907 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

C#
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!
Posted
Updated 10-Jan-12 3:41am
v2
Comments
Manfred Rudolf Bihy 10-Jan-12 9:42am    
Added code tags for formatting. If you insert code please use the correct code tags.

Thanks for your cooperation!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900