Пример #1
0
        public void ExcelPackageHelper_GetWorksheet_Null()
        {
            //arrange
            ExcelPackage package = new ExcelPackage();
            string       name    = "Title";
            //act
            ExcelWorksheet worksheet = ExcelPackageHelper.GetWorksheet(package, name);

            //assert
            Assert.AreEqual(null, worksheet);
        }
Пример #2
0
        public void ExcelPackageHelper_GetWorksheet()
        {
            //arrange
            ExcelPackage   package    = new ExcelPackage();
            string         name       = "Title";
            ExcelWorksheet worksheetA = ExcelPackageHelper.AddWorksheet(package, name);
            //act
            ExcelWorksheet worksheetB = ExcelPackageHelper.GetWorksheet(package, name);

            //assert
            Assert.AreEqual(worksheetA, worksheetB);
        }
Пример #3
0
        public TaskSheet(ExcelPackage excelPackage, string name, bool isActive)
        {
            this.isActive = isActive;
            ExcelWorksheet sheet = ExcelPackageHelper.GetWorksheet(excelPackage, name);

            columnLayout = (sheet == null) ? new ColumnLayout() : new ColumnLayout(sheet);
            if (!columnLayout.ValidLayout)
            {
                MessageBox.Show("Worksheet layout not recognized. Cannot load tasks.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);                 //todo this is model level, should just throw exception to higher view level for message display
                return;
            }
            Tasks = LoadTasks(sheet);
        }
Пример #4
0
        public ConfigSheet(ExcelPackage excelPackage)
        {
            ExcelWorksheet configSheet = ExcelPackageHelper.GetWorksheet(excelPackage, SHEET_NAME);

            if (configSheet == null)
            {
                AddDefaultConfigSheet(excelPackage);
                return;
            }

            List <object> statuses = ExcelPackageHelper.GetColumnByHeader(configSheet, STATUS_NAME);
            List <object> actives  = ExcelPackageHelper.GetColumnByHeader(configSheet, ACTIVE_NAME);

            if (statuses.Count > 0)
            {
                Statuses = new List <Status>();
                for (int i = 0; i < statuses.Count; i++)
                {
                    bool isActive = true;
                    if (actives.Count > i)
                    {
                        isActive = (actives[i].ToString() == IS_ACTIVE);
                    }
                    Statuses.Add(new Status(statuses[i].ToString(), isActive));
                }
            }
            else
            {
                SetDefaultStatuses();
            }

            Categories = ExcelPackageHelper.GetColumnByHeader(configSheet, CATEGORY_NAME).Cast <string>().ToList();
            if (Categories.Count == 0)
            {
                SetDefaultCategories();
            }

            List <object> ids = ExcelPackageHelper.GetColumnByHeader(configSheet, ID_NAME);

            if (ids.Count > 0)
            {
                MaxId = (int)ids[0];
            }
            else
            {
                MaxId = DEFAULT_ID;
            }

            WriteConfigSheet(configSheet);             //standardize format
        }