G
Gani tpt
Guest
I want to print data table values into excel template in particular columns..
I done some code,but, i am not sure which method to use for placing the values in particular column.
For example, my data table values,
EmpNo Salary
A101 10000
B202 50000
M203 10000
Ref.Column Table
Emp.No ==> D
Salary ===> M
So my final excel template would be stored in corresponding columns.
In the Excel Template
D M
A101 10000
B202 50000
M203 50000
Excel::Application xlsApp = new Excel::Application();
xlsApp.Workbooks.Add(true);
var worksheet2 = xlsApp.Worksheets.Add();
worksheet2.name = "S1";
for (int i = 0; i < dt.Rows.Count; i++)
{
for (int j = 0; j < dt.Columns.Count; j++)
{
*****************************
Here i want to print in particular column of the excel sheet
How to do this
D M
A101 10000
B202 50000
M203 50000
*****************************
//string colname = dt.Rows[j].ToString();
//worksheet2.Cells[j + 1][i + 10] = dt.Rows[j];
}
}
xlsApp.Visible = true;
xlsApp.ActiveWorkbook.SaveAs(@"C:\Users\EMA10101\Desktop\test.xlsx");
xlsApp.Quit();
Continue reading...
I done some code,but, i am not sure which method to use for placing the values in particular column.
For example, my data table values,
EmpNo Salary
A101 10000
B202 50000
M203 10000
Ref.Column Table
Emp.No ==> D
Salary ===> M
So my final excel template would be stored in corresponding columns.
In the Excel Template
D M
A101 10000
B202 50000
M203 50000
Excel::Application xlsApp = new Excel::Application();
xlsApp.Workbooks.Add(true);
var worksheet2 = xlsApp.Worksheets.Add();
worksheet2.name = "S1";
for (int i = 0; i < dt.Rows.Count; i++)
{
for (int j = 0; j < dt.Columns.Count; j++)
{
*****************************
Here i want to print in particular column of the excel sheet
How to do this
D M
A101 10000
B202 50000
M203 50000
*****************************
//string colname = dt.Rows[j].ToString();
//worksheet2.Cells[j + 1][i + 10] = dt.Rows[j];
}
}
xlsApp.Visible = true;
xlsApp.ActiveWorkbook.SaveAs(@"C:\Users\EMA10101\Desktop\test.xlsx");
xlsApp.Quit();
Continue reading...