其他分享
首页 > 其他分享> > 判断该sheet页中是否有内容,放入DT里

判断该sheet页中是否有内容,放入DT里

作者:互联网

   #region//判断该sheet页中是否有内容,放入DT里  
                            //DataTable dt = new DataTable();//把vsheet放在DT里
                            //if (vsheet.Dimension != null)
                            //{
                            //    //有效内容的起始坐标
                            //    ExcelCellAddress start = vsheet.Dimension.Start;
                            //    //有效内容的终止坐标
                            //    ExcelCellAddress end = vsheet.Dimension.End;
                            //    for (int col = start.Column; col <= end.Column; col++)
                            //    {
                            //        dt.Columns.Add(vsheet.Cells[1, col].Value != null ? vsheet.Cells[1, col].Value.ToString() : col.ToString());
                            //    }
                            //    for (int row = 2; row <= end.Row; row++)
                            //    {
                            //        DataRow dataRow = dt.NewRow();
                            //        int x = 0;
                            //        for (int col = start.Column; col <= end.Column; col++)
                            //        {
                            //            dataRow[x++] = vsheet.Cells[row, col].Value?.ToString();
                            //        }
                            //        dt.Rows.Add(dataRow);
                            //    }
                            //}
                            #endregion 判断该sheet页中是否有内容,放入DT里
View Code

 

标签:sheet,Dimension,start,ExcelCellAddress,vsheet,DT,放入
来源: https://www.cnblogs.com/aijiao/p/15469350.html