G
gauri
hi,
im a new member of the group...
im wrking on a project in asp.net web application. i have to populate
an owc spreadsheet from an sql database. i have installed the owc11
tool kit and hav this spreadsheet control in my tool bar... i have
dragged and dropped it into a web form. but the problem is tat, i am
not being able to populate the spreadsheet from the code behind(C#).
here is the code that i've written.... plz help me soon.......
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using mscomctl;
using System.Diagnostics;
using OWC10;
using System.IO;
amespace test
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
SqlConnection oConnection;
SqlCommand oCmd;
SqlDataReader oDataR;
private void Button1_Click(object sender, System.EventArgs e)
{
try
{
oConnection = new SqlConnection("Persist Security Info=False;User
ID=sa;Pwd=sa;Initial Catalog=testdb;Data Source=172.25.26.216");
oConnection.Open();
oCmd=new SqlCommand();
oCmd.Connection=oConnection;
oCmd.CommandText="Select * from tb1";
oDataR = oCmd.ExecuteReader();
SpreadsheetClass sprSht = new SpreadsheetClass();
sprSht.GetType();
int rowCount = 0;
rowCount++;
for(int colCount = 0;colCount < oDataR.FieldCount;
colCount++)
{
sprSht.ActiveSheet.Cells[rowCount,colCount + 1]
=oDataR.GetName(colCount).ToString();
}
while (oDataR.Read())
{
string data=oDataR.GetValue(0).ToString();
rowCount++;
for(int colCount = 0;colCount < oDataR.FieldCount;colCount++)
{
sprSht.ActiveSheet.Cells[rowCount,colCount + 1] =
oDataR.GetValue(colCount).ToString();
}
}
}
catch(Exception ex)
{
string error=ex.Message;
}
finally
{
oConnection.Close();
}
}
}
}
im a new member of the group...
im wrking on a project in asp.net web application. i have to populate
an owc spreadsheet from an sql database. i have installed the owc11
tool kit and hav this spreadsheet control in my tool bar... i have
dragged and dropped it into a web form. but the problem is tat, i am
not being able to populate the spreadsheet from the code behind(C#).
here is the code that i've written.... plz help me soon.......
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using mscomctl;
using System.Diagnostics;
using OWC10;
using System.IO;
amespace test
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
SqlConnection oConnection;
SqlCommand oCmd;
SqlDataReader oDataR;
private void Button1_Click(object sender, System.EventArgs e)
{
try
{
oConnection = new SqlConnection("Persist Security Info=False;User
ID=sa;Pwd=sa;Initial Catalog=testdb;Data Source=172.25.26.216");
oConnection.Open();
oCmd=new SqlCommand();
oCmd.Connection=oConnection;
oCmd.CommandText="Select * from tb1";
oDataR = oCmd.ExecuteReader();
SpreadsheetClass sprSht = new SpreadsheetClass();
sprSht.GetType();
int rowCount = 0;
rowCount++;
for(int colCount = 0;colCount < oDataR.FieldCount;
colCount++)
{
sprSht.ActiveSheet.Cells[rowCount,colCount + 1]
=oDataR.GetName(colCount).ToString();
}
while (oDataR.Read())
{
string data=oDataR.GetValue(0).ToString();
rowCount++;
for(int colCount = 0;colCount < oDataR.FieldCount;colCount++)
{
sprSht.ActiveSheet.Cells[rowCount,colCount + 1] =
oDataR.GetValue(colCount).ToString();
}
}
}
catch(Exception ex)
{
string error=ex.Message;
}
finally
{
oConnection.Close();
}
}
}
}