Ejemplo n.º 1
0
        public void ExcelPackageHelper_AppendRow_GetRow()
        {
            //arrange
            ExcelPackage   package   = new ExcelPackage();
            string         name      = "Title";
            ExcelWorksheet worksheet = ExcelPackageHelper.AddWorksheet(package, name);
            List <object>  row1      = new List <object>()
            {
                null, 123, "abc", "", new DateTime(1999, 3, 2)
            };
            List <object> row2 = new List <object>()
            {
                456, "", null, null, null, null, 789
            };

            //act
            ExcelPackageHelper.AppendRow(worksheet, row1);
            ExcelPackageHelper.AppendRow(worksheet, row2);
            List <object> result1 = ExcelPackageHelper.GetRow(worksheet, 1);
            List <object> result2 = ExcelPackageHelper.GetRow(worksheet, 2);

            //assert
            Assert.AreEqual(2, ExcelPackageHelper.CountRows(worksheet));
            Assert.AreEqual(Math.Max(row1.Count, row2.Count), ExcelPackageHelper.CountColumns(worksheet));
            for (int i = 0; i < row1.Count; i++)
            {
                Assert.AreEqual(row1[i], result1[i]);
            }
            for (int i = 0; i < row2.Count; i++)
            {
                Assert.AreEqual(row2[i], result2[i]);
            }
        }