如何合并数据视图值
我想将相同的数据视图值合并到另一个数据视图..
我的代码在这里:
for (int i = 0; i < lbxempname.Items.Count; i++)
{
if (lbxempname.Items[i].Selected)
{
string id = lbxempname.Items[i].Text;
string substr = id.Substring(0, 8);
string Expression = "Employee_ID='" + substr + "' and Punchdate >=#" + txtstartdate.Text + "# and Punchdate <=#" + txtenddate.Text + "#";
DataSet4TableAdapters.sp_getalltimesheetTableAdapter TA1 = new DataSet4TableAdapters.sp_getalltimesheetTableAdapter();
DataSet4.sp_getalltimesheetDataTable DS1 = TA1.GetData();
datavw = DS1.DefaultView;
datavw.RowFilter = Expression;
}
newdatavw = new DataView ();
newdatavw.Table.Merge(datavw.Table);
}
第一个循环,数据视图有一些像这样的记录...
EmployeeId EmployeeName Department Date Day Intime Outtime Late_After Early_Before Remarks
00626243 HariharanJ SBS IT 01-04-2012 Wednesday 06:40:00 15:00:00 00:00 00:00 P
00626243 HariharanJ SBS IT 01-03-2012 Tuesday 00:00:00 14:40:00 00:00 00:05 P
00626243 HariharanJ SBS IT 01-05-2012 Thursday 07:00:00 14:35:00 00:20 00:10 P
第二个也有一些具有相同标题的记录.. 但我想将两条记录导出到一个 Excel 中,并为每条记录添加标题和单个制动器。请我创建它时遇到麻烦。我可以将单个记录导出到 Excel,但我无法导出所有记录...
I want to merge same dataview value to another dataview ..
My code is here:
for (int i = 0; i < lbxempname.Items.Count; i++)
{
if (lbxempname.Items[i].Selected)
{
string id = lbxempname.Items[i].Text;
string substr = id.Substring(0, 8);
string Expression = "Employee_ID='" + substr + "' and Punchdate >=#" + txtstartdate.Text + "# and Punchdate <=#" + txtenddate.Text + "#";
DataSet4TableAdapters.sp_getalltimesheetTableAdapter TA1 = new DataSet4TableAdapters.sp_getalltimesheetTableAdapter();
DataSet4.sp_getalltimesheetDataTable DS1 = TA1.GetData();
datavw = DS1.DefaultView;
datavw.RowFilter = Expression;
}
newdatavw = new DataView ();
newdatavw.Table.Merge(datavw.Table);
}
First looping, dataview have some records like this...
EmployeeId EmployeeName Department Date Day Intime Outtime Late_After Early_Before Remarks
00626243 HariharanJ SBS IT 01-04-2012 Wednesday 06:40:00 15:00:00 00:00 00:00 P
00626243 HariharanJ SBS IT 01-03-2012 Tuesday 00:00:00 14:40:00 00:00 00:05 P
00626243 HariharanJ SBS IT 01-05-2012 Thursday 07:00:00 14:35:00 00:20 00:10 P
and second also having some records with same header..
But i want to Export both records in a single Excel with header and a single brake for each record. Please i was trouble to create it.I can Export a single record to excel but i can't export all record...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更改上面的代码:
DataView.ToTable();
==>使用 DataView 返回一个新的 DataTablechange your Code above:
DataView.ToTable();
==>Return a new DataTable with DataView