判断该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
C#.net. WPF.core 技术交流群 群号205082182,欢迎加入,也可以直接点击左侧和下方的"加入QQ群",直接加入
原文地址:https://www.cnblogs.com/aijiao/p/15469350.html