C# 如何遍历数据表单元格
我需要得到一个数据表中所有单元格的计数,我该怎么做?在将数据插入数据库之前,我需要验证我的两个表是否具有相同的单元格数量。请尝试以下操作:C# 如何遍历数据表单元格,c#,.net,C#,.net,我需要得到一个数据表中所有单元格的计数,我该怎么做?在将数据插入数据库之前,我需要验证我的两个表是否具有相同的单元格数量。请尝试以下操作: DataTable dt1 = new DataTable(), dt2 = new DataTable(); // define and populate your tables int count1 = dt1.Columns.Count * dt1.Rows.Count; int count2 = dt2.Colum
DataTable dt1 = new DataTable(), dt2 = new DataTable();
// define and populate your tables
int count1 = dt1.Columns.Count * dt1.Rows.Count;
int count2 = dt2.Columns.Count * dt2.Rows.Count;
bool verified = count1 == count2;
试试这个:
DataTable dt1 = new DataTable(), dt2 = new DataTable();
// define and populate your tables
int count1 = dt1.Columns.Count * dt1.Rows.Count;
int count2 = dt2.Columns.Count * dt2.Rows.Count;
bool verified = count1 == count2;
var nCells=dt.Rows.Count*dt.Columns.Count
@CodeIgnoto是的,我正在使用open.xml读取excel工作表,但此sdk会忽略空行。因此,我想检查excel文件datatable是否具有与数据库datatable相同的单元格计数。var nCells=dt.Rows.count*dt.Columns.count
@CodeIgnoto是的,我正在使用open.xml读取excel工作表,但此sdk会忽略空行。因此,我想检查excel文件datatable的单元格数是否与数据库datatable的单元格数相同。这不会得到OP请求的datatable中所有单元格的计数,它只是循环单元格。是的,我知道,我回答了如何迭代datatable单元格这不会得到OP请求的datatable中所有单元格的计数,它只是循环单元格。是的,我知道,我回答了如何迭代数据表单元格