{"id":25714356,"url":"https://github.com/bvkeersop/documentbuilder","last_synced_at":"2025-08-03T13:05:36.875Z","repository":{"id":50481790,"uuid":"516464653","full_name":"bvkeersop/DocumentBuilder","owner":"bvkeersop","description":"DEPRECATED: No longer maintained. DocumentBuilder is a library that uses the builder pattern to easily create different kinds of documents.","archived":false,"fork":false,"pushed_at":"2023-10-05T12:30:46.000Z","size":482,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-01T02:02:11.071Z","etag":null,"topics":["builder","builder-design-pattern","builder-pattern","docs","documentation","documentation-generator","documentation-tool","excel","excel-converter","html","html-converter","markdown","markdown-converter"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bvkeersop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-21T17:32:54.000Z","updated_at":"2023-10-05T12:26:22.000Z","dependencies_parsed_at":"2025-02-25T13:03:29.626Z","dependency_job_id":null,"html_url":"https://github.com/bvkeersop/DocumentBuilder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bvkeersop/DocumentBuilder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bvkeersop%2FDocumentBuilder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bvkeersop%2FDocumentBuilder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bvkeersop%2FDocumentBuilder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bvkeersop%2FDocumentBuilder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bvkeersop","download_url":"https://codeload.github.com/bvkeersop/DocumentBuilder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bvkeersop%2FDocumentBuilder/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268547622,"owners_count":24267673,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["builder","builder-design-pattern","builder-pattern","docs","documentation","documentation-generator","documentation-tool","excel","excel-converter","html","html-converter","markdown","markdown-converter"],"created_at":"2025-02-25T12:53:15.132Z","updated_at":"2025-08-03T13:05:36.852Z","avatar_url":"https://github.com/bvkeersop.png","language":"C#","readme":"# DEPRECATED\n\nI don't maintain this project anymore. I originally made this project because I wanted a way to create markdowndocuments in C#. I decided on the fly to also add different kinds of documents, that I have no need for. I think the project does too much and I'm not happy with some of the design choices I made. I'll be creating a seperate project just for markdowndocument creation.\n\n# DocumentBuilder\n\n![Workflows: dotnet](https://github.com/bvkeersop/DocumentBuilder/actions/workflows/pipeline.yml/badge.svg)\n![GitHub](https://img.shields.io/github/license/bvkeersop/DocumentBuilder)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=bvkeersop_DocumentBuilder\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=bvkeersop_DocumentBuilder)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=bvkeersop_DocumentBuilder\u0026metric=coverage)](https://sonarcloud.io/summary/new_code?id=bvkeersop_DocumentBuilder)\n\n`DocumentBuilder` is a library that uses the `Builder` pattern to enable you to declaratively create different kinds of documents easily.\nIt is **not** a full-fledged solution for creating complex documents. `DocumentBuilder` focuses on ease of use.\n\nThe following formats are currently supported:\n\n- Markdown\n- HTML\n- Excel\n\n`DocumentBuilder` exposes a `GenericDocumentBuilder` class that can be used to create a markdown or HTML document, it does not support Excel since its document structure is too different. `DocumentBuilder` also exposes a `MarkdownDocumentBuilder` and an `HTMLDocumentBuilder`. These can be extended with Markdown or HTML-specific elements.\n\n# Table of Contents\n\n- [DocumentBuilder](#documentbuilder)\n- [Table of Contents](#table-of-contents)\n  - [Creating a document](#creating-a-document)\n    - [Generic](#generic)\n    - [Markdown](#markdown)\n    - [HTML](#html)\n    - [Excel](#excel)\n  - [Tables](#tables)\n    - [Creating a Table](#creating-a-table)\n      - [1. Define a POCO](#1-define-a-poco)\n      - [2. Put your POCOs in an IEnumerable](#2-put-your-pocos-in-an-ienumerable)\n      - [3. Use it inside a document builder to generate a table](#3-use-it-inside-a-document-builder-to-generate-a-table)\n  - [Options](#options)\n  - [DocumentOptions](#documentoptions)\n  - [Markdown](#markdown-1)\n      - [MarkdownTableOptions](#markdowntableoptions)\n  - [HTML](#html-1)\n      - [HtmlDocumentOptions](#htmldocumentoptions)\n    - [Attributes](#attributes)\n  - [Credits](#credits)\n  - [Future work](#future-work)\n\n## Creating a document\n\nBelow are examples of how you can use the document builders provided by `DocumentBuilder` to create markdown, HTML and Excel documents. You can write your document to a stream by providing an output stream, or to a file by providing a file path.\n\n```C#\n\n// Given the following data:\nvar header1 = \"Header1\";\nvar header2 = \"Header2\";\nvar header3 = \"Header3\";\nvar header4 = \"Header4\";\nvar paragraph = \"An interesting paragraph\";\nvar imageName = \"imageName\";\nvar imagePath = \"./image\";\nvar imageCaption = \"This is an image\";\nvar blockquote = \"blockquote\";\nvar lanuage = \"C#\";\nvar codeblock = \"codeblock\";\nvar raw = \"raw\";\n\nvar orderedList = new List\u003cstring\u003e\n{\n    \"an\",\n    \"ordered\",\n    \"list\"\n};\n\nvar unorderedList = new List\u003cstring\u003e\n{\n    \"an\",\n    \"unordered\",\n    \"list\"\n};\n\n```\n\n### Generic\n\nThe generic document builder allows you to create generic documents that can easily be written to a stream as either Markdown or HTML.\n\n```C#\n\n// Create a document using the generic document builder\nvar outputStream = new MemoryStream();\n\nvar documentBuilder = new DocumentBuilder(options)\n    .AddHeader1(header1)\n    .AddHeader2(header2)\n    .AddHeader3(header3)\n    .AddHeader4(header4)\n    .AddParagraph(paragraph)\n    .AddImage(imageName, imagePath, imageCaption)\n    .AddUnorderedList(unorderedList)\n    .AddOrderedList(orderedList)\n    .AddTable(productTableRows) // More on tables below\n    .BuildAsync(outputStream, DocumentType.Markdown); // Or HTML (DocumentType.HTML)\n\n```\n\n### Markdown\n\nThe `MarkdownDocumentBuilder` allows you to create Markdown documents, it is not yet different from the `GenericDocumentBuilder`, but might include Markdown-specific functionality in the future.\n\n```C#\n\n// Create a document using the markdown document builder\nvar outputStream = new MemoryStream();\n\nvar markdownDocumentBuilder = new MarkdownDocumentBuilder(options)\n    .AddHeader1(header1)\n    .AddHeader2(header2)\n    .AddHeader3(header3)\n    .AddHeader4(header4)\n    .AddParagraph(paragraph)\n    .AddImage(imageName, imagePath, imageCaption)\n    .AddUnorderedList(unorderedList)\n    .AddOrderedList(orderedList)\n    .AddTable(productTableRows) // More on tables below\n    .AddHorizontalRule()\n    .AddBlockquote(blockquote)\n    .AddFencedCodeblock(codeblock, language)\n    .AddRaw(raw)\n    .BuildAsync(outputStream); // Or file path\n\n```\n\n### HTML\n\nThe `HTMLDocumentBuilder` allows you to create Markdown documents, it is not yet different from the `GenericDocumentBuilder`, but might include HTML-specific functionality in the future.\n\n```C#\n\n// Create a document using the html document builder\nvar outputStream = new MemoryStream();\n\nvar htmlDocumentBuilder = new HtmlDocumentBuilder(options)\n    .AddHeader1(header1)\n    .AddHeader2(header2)\n    .AddHeader3(header3)\n    .AddHeader4(header4)\n    .AddImage(imageName, imagePath, imageCaption)\n    .AddParagraph(paragraph)\n    .AddUnorderedList(unorderedList)\n    .AddOrderedList(orderedList)\n    .AddTable(productTableRows) // More on tables below\n    .AddRaw(raw)\n    .BuildAsync(outputStream); // Or file path\n```\n\n### Excel\n\nThe Excel document builder allows you to create Excel documents. Since the structure of Excel documents is not comparable to Markdown or HTML, it's not supported by the `GenericDocumentBuilder`.\n\n```C#\n\n// Create a document using the excel document builder\nvar outputStream = new MemoryStream();\n\nvar excelDocumentBuilder = new ExcelDocumentBuilder(options)\n    .AddWorksheet(\"my-worksheet-name\")\n    .AddTable(productTableRows) // More on tables below\n    .BuildAsync(outputStream);  // Or file path\n```\n\n## Tables\n\n`DocumentBuilder` supports the creation of tables by creating a POCO (Plain Old C# Object). It will use the name of the property as the column name and will order the columns as defined on the POCO. There are [options](#options) available to configure this.\n\n### Creating a Table\n\n#### 1. Define a POCO\n\n```C#\n\npublic class ProductTableRow\n{\n    public string Id { get; set; }\n    public string Amount { get; set; }\n    public string Price { get; set; }\n    public string Description { get; set; }\n}\n\n```\n\n#### 2. Put your POCOs in an IEnumerable\n\n```C#\n\nvar productTableRows = new List\u003cProductTableRow\u003e\n{\n    productTableRowOne,\n    productTableRowTwo,\n    productTableRowThree,\n};\n\n```\n\n#### 3. Use it inside a document builder to generate a table\n\n```C#\n\nvar outputStream = new MemoryStream();\n\nvar markdownDocumentBuilder = new MarkdownDocumentBuilder(options)\n    .AddTable(productTableRows)\n    .BuildAsync(outputStream);\n\n```\n\n\u003e NOTE: In case of using an object, the values written to the table cell will be the object's `ToString()` method.\n\nIf the provided table row is an empty enumerable, it will be skipped.\n\n## Options\n\n## DocumentOptions\n\nAll document types have the following options:\n\n| Option                    | Type                    | Description                                                  | DefaultValue |\n| ------------------------- | ----------------------- |------------------------------------------------------------- | ------------ |\n| LineEnding                | LineEnding              | What line ending to use                                      | Environment  |\n| BehaviorOnEmptyEnumerable | EmptyEnumerableBehavior | What behavior to display when a provided enumerable is empty | SkipRender   |\n\n\u003e **LineEndings**: *Environment, Windows, Linux*\n\u003e **EmptyEnumerableBehavior**: *SkipRender, Render, ThrowException*\n\n## Markdown\n\n#### MarkdownTableOptions\n\n| Option                  | Type           | Description                                  | DefaultValue |\n| ----------------------- | ---------------|--------------------------------------------- | ------------ |\n| Formatting              | Formatting     | How to align the table                       | AlignColumns |\n| BoldColumnNames         | bool           | Wheter to have the column names in bold text | false        |\n| DefaultAlignment        | Alignment      | What default (github) alignment to use       | None         |\n\n\u003e **Formatting**: *AlignColumns, None*\n\u003e **Alignment**: *None, Left, Right, Center*\n\n## HTML\n\n#### HtmlDocumentOptions\n\n| Option                  | Type            | Description                     | DefaultValue |\n| ----------------------- | ----------------|-------------------------------- | ------------ |\n| LineEnding              | LineEnding      | What line ending to use         | Environment  |\n| IndentationType         | IndentationType | What type of indentation to use | Spaces       |\n| IndentationSize         | int             | The size of one indentation     | 2            |\n\n\u003e **IndentationTypes**: *Spaces, Tabs*\n\n### Attributes\n\nYou can annotate your POCO properties with the `Column` attribute.\n\n``` C#\n\npublic class ProductTableRow\n{\n    [Column(name: \"ProductId\", order: 1)] // Overwrite the column name\n    public string Id { get; set; }\n\n    [Column(nameof(Description))] // Not specifying an order will default the value to int.Max\n    public string Description { get; set; }\n\n    public string Price { get; set; }\n\n    [Column(alignment: Alignment.Center)] // Applies github style markdown to align the column\n    public string Amount { get; set; }\n}\n\n```\n\nYou can annotate your POCO properties with the `IgnoreColumn` attribute. This will ignore the column when converting to a document.\n\n``` C#\n\npublic class ProductTableRow\n{\n    [Column(name: \"ProductId\", order: 1)] // Overwrite the column name\n    public string Id { get; set; }\n\n    [Column(nameof(Description))] // Not specifying an order will default the value to int.Max\n    public string Description { get; set; }\n\n    [IgnoreColumn]\n    public string Price { get; set; }\n\n    [Column(alignment: Alignment.Center)] // Applies github style markdown to align the column\n    public string Amount { get; set; }\n}\n\n```\n\n## Credits\n\n`DocumentBuilder` is made possible by the following projects:\n\n- [ClosedXML](https://github.com/ClosedXML/ClosedXML)\n- [FluentAssertions](https://fluentassertions.com/)\n- [NSubstitute](https://nsubstitute.github.io/)\n\n## Future work\n\nIf there are any features that you would like to see implemented, please create an issue with the `enhancement` label on the [Github Issues](https://github.com/bvkeersop/DocumentBuilder/issues) page. Note that I am working on this project in my free time, and might not have time to implement your request (or simply decline it since I don't see the added value for the project).\n\nCurrently, I'm still looking to implement the following (no deadline set):\n\n- Word support\n- More insertables for Excel\n- Better styling options for Excel","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbvkeersop%2Fdocumentbuilder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbvkeersop%2Fdocumentbuilder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbvkeersop%2Fdocumentbuilder/lists"}