{"id":21317211,"url":"https://github.com/oldrev/sandwych-formula-parser","last_synced_at":"2025-03-15T21:44:04.816Z","repository":{"id":174323174,"uuid":"646734317","full_name":"oldrev/sandwych-formula-parser","owner":"oldrev","description":"Excel like formula parser for .NET","archived":false,"fork":false,"pushed_at":"2023-06-11T02:43:53.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-22T10:47:19.551Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oldrev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-05-29T08:11:44.000Z","updated_at":"2023-06-11T02:42:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"ed145dc8-a9b2-40c2-96c6-2f25b8605663","html_url":"https://github.com/oldrev/sandwych-formula-parser","commit_stats":null,"previous_names":["oldrev/sandwych-formula-parser"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oldrev%2Fsandwych-formula-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oldrev%2Fsandwych-formula-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oldrev%2Fsandwych-formula-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oldrev%2Fsandwych-formula-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oldrev","download_url":"https://codeload.github.com/oldrev/sandwych-formula-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243796647,"owners_count":20349252,"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","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":[],"created_at":"2024-11-21T18:42:27.549Z","updated_at":"2025-03-15T21:44:04.800Z","avatar_url":"https://github.com/oldrev.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sandwych.FormulaParser\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n**Sandwych.FormulaParser** is a .NET C# library that provides a toy-level Excel formula parser for concept verification. It is built on top of the Parlot parsing combinator library. This parser allows you to evaluate and process custom formulas, providing a foundation for building more complex expression evaluation systems.\n\n## Features\n\n- Parse and evaluate Excel-like formulas\n- Support for basic mathematical operators (`+`, `-`, `*`, `/`, `^`)\n- Built-in functions such as `SUM`, `AVERAGE`, `MAX`, `MIN`, etc.\n- Ability to define and use custom functions\n- Support for cell references (e.g., `A1`, `B2`, etc.)\n- Error handling and reporting for invalid formulas or references\n- MIT licensed for free and open-source use\n\n## Project Status\n\nCurrent status: WORKING-IN-PROGRESS\n\n## Installation\n\nTo use Sandwych.FormulaParser in your .NET C# project, you can either:\n\n- Clone the repository and reference the project directly.\n- Install the package from NuGet using the following command:\n\n  ```bash\n  dotnet add package Sandwych.FormulaParser\n  ```\n\n## Usage\n\nTo parse and evaluate an Excel formula using Sandwych.FormulaParser, follow these steps:\n\n```csharp\nvar sheet1 = new Sheet();\nsheet1[\"$A$12\"] = new CellValue(10.0);\nsheet1[\"C13\"] = new CellValue(100.0);\n\nvar scope = new Scope(sheet1.TryGetCellValue);\n\nvar exprText = \"ADDALL(SUM(1.0, 2.0, $A$12), 100.0) + C13 + 10 ^ 2\";\n\n// Custom functions\nvar customFunctions = new (string, Expression)[]\n{\n    (\"ADDALL\", (IEnumerable\u003cdouble\u003e args) =\u003e args.Aggregate((x, y) =\u003e x + y)),\n    (\"SUM\", (IEnumerable\u003cdouble\u003e args) =\u003e args.Sum()),\n    (\"AVG\", (IEnumerable\u003cdouble\u003e args) =\u003e args.Average()),\n    (\"MAX\", (IEnumerable\u003cdouble\u003e args) =\u003e args.Max()),\n    (\"MIN\", (IEnumerable\u003cdouble\u003e args) =\u003e args.Min()),\n};\n\nvar compiler = new FormulaCompiler(customFunctions);\n\n// Compile to .NET IL code and return as a delegate\nvar dg = compiler.Compile(exprText);\n\n// Invoke the compiled delegate\nvar result = dg(scope);\n\n// Output the result\nConsole.WriteLine($\"Cell $A$12 = {scope.GetCellValue(CellAddress.Parse(\"$A$12\"))}\");\nConsole.WriteLine($\"Cell C13 = {scope.GetCellValue(CellAddress.Parse(\"C13\"))}\");\nConsole.WriteLine($\"{exprText} = {result}\");\n\n```\n\n## Contributing\n\nContributions are welcome! If you find any bugs or would like to suggest new features, please create an issue or submit a pull request on the \n[GitHub repository](https://github.com/oldrev/Sandwych.FormulaParser).\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foldrev%2Fsandwych-formula-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foldrev%2Fsandwych-formula-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foldrev%2Fsandwych-formula-parser/lists"}