在读EXCEL到GV产生了一部分空白的数据请问在读取的时候有没办法直接删除?
意思就是显示出的数据无空白的。

解决方案 »

  1.   

    private void RemoveNullRows()
            {
                bool isNullRow=true;
                for (int i = this.RowCount - 1; i >= 0; i++)
                {
                    foreach (DataGridViewCell cell in this.Rows[i].Cells)
                    {
                        if (cell.Value != null && string.IsNullOrEmpty(cell.Value.Str()) == false)
                        {
                            isNullRow = false;
                            break;
                        }
                    }                if (isNullRow == true)
                    {
                        this.Rows.RemoveAt(i);                  
                    }                isNullRow = true;
                }
            }