C# excel worksheet abstraction

Date: 2019-10-24
public class ExportCell
{
	public ExportCell(object value)
	{
		Value = value;
	}
	public object Value;
	public string Formula;
	public string Comment;
}

public class ExportRow : IEnumerable<ExportCell>
{
	public List<ExportCell> ExportCellList { get; set; } = new List<ExportCell>();

	public IEnumerator<ExportCell> GetEnumerator()
	{
		return ExportCellList.GetEnumerator();
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ExportCellList.GetEnumerator();
	}

	public ExportCell Add(object value)
	{
		var cell = new ExportCell(value);
		ExportCellList.Add(cell);
		return cell;
	}
}

public class ExportWorksheet
{
	public string Title { get; set; }
	public List<string> ColumnTitles = new List<string>();
	public List<ExportRow> Rows = new List<ExportRow>();

	public ExportWorksheet(string title = "Worksheet 1")
	{
		Title = title;
	}

	public ExportRow NewRow()
	{
		var row = new ExportRow();
		Rows.Add(row);
		return row;
	}
}
27050cookie-checkC# excel worksheet abstraction