[TestMethod]
        public void Test()
        {
            _config = new AppSettingOptions() { ResDir = "D:\\VR2\\" };
            var resDir = _config.ResDir;
            if (Directory.Exists(resDir))
            {
                DirectoryInfo dir = new DirectoryInfo(resDir);
                FileInfo[] files = dir.GetFiles("*.xlsx");
                foreach (FileInfo file in files)
                {
                    string filePath = file.FullName;
                    var workbook = new XSSFWorkbook(filePath);
                    var sheet01 = workbook.GetSheet("活动");
                    int rowCount = sheet01.LastRowNum;//总行数
                    if (rowCount > 0)
                    {
                        IRow firstRow = sheet01.GetRow(0);//第一行
                        int cellCount = firstRow.LastCellNum;//列数
                        var rowList = new List<string>();
                        for (int i = 1; i <= rowCount; i++)
                        {
                            var row = sheet01.GetRow(i);
                            if (row == null) continue;
                            foreach (var cell in row.Cells)
                            {
                                rowList.Add(cell.ToString());
                            }
                        }
                    }

                }
            }
        }

 

分类:

技术点:

相关文章: