mathieu_cupryk
asked on
Convert C# to vb.net urgent?
try
{
DataTable dt = new DataTable();
objDB = new DatabaseToExcel.DB(Connect ionString) ;
dt = objDB.runQuery(query);
ctl_progress.Visible = true;
ctl_progress.Minimum = 1;
ctl_progress.Maximum = dt.Rows.Count + 1;
ctl_progress.Value = 1;
//This is to access the first work sheet of your application
sheet = (Excel.Worksheet)book.Work sheets[1];
sheet.Name = "SampleExcel";
for(int i = 1 ; i <= dt.Rows.Count ; i++)
{
for(int j = 1 ; j <= dt.Columns.Count ; j++ )
{
// This is to add the Data which retrieved from
// the database into your Excel Sheet.
((Excel.Range)sheet.Cells[ i,j]).Valu e2
= dt.Rows[i-1].ItemArray[j-1 ].ToString ();
//dt.Rows[i-1].ItemArray[j -1].ToStri ng()--> This will retrieve
// data from your datatable's
//(i-1)th rows (j-1)st column
}
ctl_progress.Value += 1;
}
MessageBox.Show("Your Process Completed Successfully");
ctl_progress.Visible = false;
}
catch(Exception e1)
{
MessageBox.Show(e1.Message );
}
{
DataTable dt = new DataTable();
objDB = new DatabaseToExcel.DB(Connect
dt = objDB.runQuery(query);
ctl_progress.Visible = true;
ctl_progress.Minimum = 1;
ctl_progress.Maximum = dt.Rows.Count + 1;
ctl_progress.Value = 1;
//This is to access the first work sheet of your application
sheet = (Excel.Worksheet)book.Work
sheet.Name = "SampleExcel";
for(int i = 1 ; i <= dt.Rows.Count ; i++)
{
for(int j = 1 ; j <= dt.Columns.Count ; j++ )
{
// This is to add the Data which retrieved from
// the database into your Excel Sheet.
((Excel.Range)sheet.Cells[
= dt.Rows[i-1].ItemArray[j-1
//dt.Rows[i-1].ItemArray[j
// data from your datatable's
//(i-1)th rows (j-1)st column
}
ctl_progress.Value += 1;
}
MessageBox.Show("Your Process Completed Successfully");
ctl_progress.Visible = false;
}
catch(Exception e1)
{
MessageBox.Show(e1.Message
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.kamalpatel.net/ConvertCSharp2VB.aspx