public void WriteTo(ExcelPackage package) { ExcelWorksheet worksheet = ExcelPackageHelper.AddWorksheet(package, GetSheetName()); ColumnLayout.WriteTaskHeaders(worksheet, isActive); foreach (Task task in Tasks) { columnLayout.WriteTask(worksheet, task, isActive); } }
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); }
public TaskSheet(MSExcel2003XmlFile xmlFile, string worksheetTitle, bool isActive) { Init(isActive); int tableIndex = xmlFile.GetTableIndex(worksheetTitle); if (tableIndex == -1) { return; } columnLayout = new ColumnLayout(xmlFile.GetRowValues(tableIndex, 0)); for (int rowIndex = 1; rowIndex < xmlFile.GetRowCount(tableIndex); rowIndex++) { Tasks.Add(new Task(xmlFile.GetRowValues(tableIndex, rowIndex), columnLayout)); } }
public Task(List <string> values, ColumnLayout columnLayout) { char columnChar = 'A'; foreach (string value in values) { string header = columnLayout.GetHeaderByColumnChar(columnChar.ToString()); switch (header) { case ColumnLayout.ID_HEADER: Id = Int32.Parse(value); break; case ColumnLayout.DESCRIPTION_HEADER: Description = value; break; case ColumnLayout.STATUS_HEADER: Status = value; break; case ColumnLayout.CATEGORY_HEADER: Category = value; break; case ColumnLayout.CREATE_DATE_HEADER: CreateDate = DateTime.Parse(value); break; case ColumnLayout.DONE_DATE_HEADER: DoneDate = DateTime.Parse(value); break; } columnChar++; } }
//--------------------------------------------------- private void Init(bool isActive) { this.isActive = isActive; columnLayout = new ColumnLayout(); Tasks = new List <Task>(); }