Ejemplo n.º 1
0
        private void WriteConfigSheet(ExcelWorksheet worksheet)
        {
            ExcelPackageHelper.Clear(worksheet);
            ExcelPackageHelper.AppendRow(worksheet, new List <object>()
            {
                STATUS_NAME, ACTIVE_NAME, "", CATEGORY_NAME, "", ID_NAME
            });
            worksheet.Cells["A1:F1"].Style.Font.Bold = true;

            ExcelPackageHelper.SetColumnByChar(worksheet, "A", Statuses.Select(s => (object)s.Name).ToList(), skipFirstRow: true);
            ExcelPackageHelper.SetColumnByChar(worksheet, "B", Statuses.Select(s => (object)(s.Active ? IS_ACTIVE : IS_INACTIVE)).ToList(), skipFirstRow: true);
            ExcelPackageHelper.SetColumnByChar(worksheet, "D", Categories.Select(c => (object)c).ToList(), skipFirstRow: true);
            ExcelPackageHelper.SetColumnByChar(worksheet, "F", new List <object>()
            {
                (object)MaxId
            }, skipFirstRow: true);
        }
Ejemplo n.º 2
0
        public void ExcelPackageHelper_Clear()
        {
            //arrange
            ExcelPackage   package   = new ExcelPackage();
            string         name      = "Title";
            ExcelWorksheet worksheet = ExcelPackageHelper.AddWorksheet(package, name);
            List <string>  row       = new List <string>()
            {
                "ColA", "ColB", "ColC"
            };

            //act
            ExcelPackageHelper.AppendRow(worksheet, row);
            ExcelPackageHelper.AppendRow(worksheet, row);
            ExcelPackageHelper.AppendRow(worksheet, row);
            ExcelPackageHelper.AppendRow(worksheet, row);
            ExcelPackageHelper.Clear(worksheet);
            int rowCount    = ExcelPackageHelper.CountRows(worksheet);
            int columnCount = ExcelPackageHelper.CountColumns(worksheet);

            //assert
            Assert.AreEqual(0, rowCount);
            Assert.AreEqual(0, columnCount);
        }