{"id":2705,"date":"2019-10-24T13:22:51","date_gmt":"2019-10-24T12:22:51","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=2705"},"modified":"2022-07-25T08:33:25","modified_gmt":"2022-07-25T07:33:25","slug":"c-excel-worksheet-abstraction","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/c-excel-worksheet-abstraction\/","title":{"rendered":"C# excel worksheet abstraction"},"content":{"rendered":"\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class ExportCell\n{\n\tpublic ExportCell(object value)\n\t{\n\t\tValue = value;\n\t}\n\tpublic object Value;\n\tpublic string Formula;\n\tpublic string Comment;\n}\n\npublic class ExportRow : IEnumerable&lt;ExportCell>\n{\n\tpublic List&lt;ExportCell> ExportCellList { get; set; } = new List&lt;ExportCell>();\n\n\tpublic IEnumerator&lt;ExportCell> GetEnumerator()\n\t{\n\t\treturn ExportCellList.GetEnumerator();\n\t}\n\n\tIEnumerator IEnumerable.GetEnumerator()\n\t{\n\t\treturn ExportCellList.GetEnumerator();\n\t}\n\n\tpublic ExportCell Add(object value)\n\t{\n\t\tvar cell = new ExportCell(value);\n\t\tExportCellList.Add(cell);\n\t\treturn cell;\n\t}\n}\n\npublic class ExportWorksheet\n{\n\tpublic string Title { get; set; }\n\tpublic List&lt;string> ColumnTitles = new List&lt;string>();\n\tpublic List&lt;ExportRow> Rows = new List&lt;ExportRow>();\n\n\tpublic ExportWorksheet(string title = \"Worksheet 1\")\n\t{\n\t\tTitle = title;\n\t}\n\n\tpublic ExportRow NewRow()\n\t{\n\t\tvar row = new ExportRow();\n\t\tRows.Add(row);\n\t\treturn row;\n\t}\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[6,4,1],"tags":[],"class_list":["post-2705","post","type-post","status-publish","format-standard","hentry","category-dotnet","category-programming","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/2705","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=2705"}],"version-history":[{"count":1,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/2705\/revisions"}],"predecessor-version":[{"id":2706,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/2705\/revisions\/2706"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=2705"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=2705"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=2705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}