コード例 #1
0
        public void AsDataSetXlsx()
        {
            IWorkbook workbook = WorkbookFactory.GetExcel2007Reader(@"..\..\Files\AsDataSet\AsDataSet.xlsx");
            DataSet   set      = workbook.AsDataSet(true);

            Assert.AreEqual(1, set.Tables.Count);
            Assert.AreEqual("Sheet1", set.Tables[0].TableName);
            Assert.AreEqual(3, set.Tables[0].Rows.Count);
            Assert.AreEqual(6, set.Tables[0].Columns.Count);

            string[] expectedCols = { "A", "B", "C", "E", "F", "G" };
            for (int i = 0; i < set.Tables[0].Columns.Count; i++)
            {
                Assert.AreEqual(expectedCols[i], set.Tables[0].Columns[i].ColumnName);
            }
        }