RemoveEndEmptyLines(ref dt2, dt2.Rows.Count - 1);
public bool IsEmptyLine(DataTable dt, int index)
{
bool isEmpty = true;
int iColCount = dt.Columns.Count;
for (int i = 0; i < iColCount; i++)
{
// Console.WriteLine(dt.Rows[index][i]);
if (!Convert.IsDBNull(dt.Rows[index][i]))
{
isEmpty = false;
break;
}
}
return isEmpty;
}
private void RemoveEndEmptyLines(ref DataTable dt, int index)
{
if (IsEmptyLine(dt, index))
{
MessageBox.Show("empty");
dt.Rows.RemoveAt(index);
RemoveEndEmptyLines(ref dt, index - 1);
}
}
没有评论:
发表评论