返回首页

您好,

我是新发展的仪表板。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();

    }

}


有其他任何方式或代码榜样?
请指导我!

回答

评论会员:Cluelesssssss 时间:2012/02/07
i = datagridview1.CurrentRow.Index

 

 Combobox1.Text = datagridview1.Item(3,i).Value
评论会员:mirzamujib 时间:2012/02/07
textobx.text=Datagridview1.selectedItem.cells(0).text
的这里'0'代表列选定的记录:吴拉姆・迈赫迪
评论会员:游客 时间:2012/02/07
{C3的}读这有更多的信息Simon_Whale]
您已输入到您的应用程序,这是作为风险的探险治疗
本hapend时的输入值与quot开始; LT"或quot;>",所以它可以解释为风险
解决方案:
LT;选择valuegt;"如果不移除值盯着与quot; <"(我喜欢的一样quot东西;然后尝试
禁用请求验证通过添加属性的ValidateRequest = quot; falsequot。@ Page指令
它是在aspx页面中的巨头,凝视着
LT;??%@语言BR />例如:
{的C4}