{"id":22065538,"url":"https://github.com/karenpayneoregon/excel-spreadsheetlight-csharp","last_synced_at":"2025-08-02T10:06:31.921Z","repository":{"id":110840544,"uuid":"495979081","full_name":"karenpayneoregon/excel-spreadsheetlight-csharp","owner":"karenpayneoregon","description":"For teaching simple Excel operations","archived":false,"fork":false,"pushed_at":"2025-01-10T14:09:51.000Z","size":1692,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-13T01:16:28.603Z","etag":null,"topics":["csharp-core","excel","netcore","spreadsheetlight"],"latest_commit_sha":null,"homepage":"","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/karenpayneoregon.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,"zenodo":null}},"created_at":"2022-05-24T20:32:00.000Z","updated_at":"2025-01-11T07:52:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"c9a5e959-30df-45c3-9634-1741e68c82d6","html_url":"https://github.com/karenpayneoregon/excel-spreadsheetlight-csharp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/karenpayneoregon/excel-spreadsheetlight-csharp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2Fexcel-spreadsheetlight-csharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2Fexcel-spreadsheetlight-csharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2Fexcel-spreadsheetlight-csharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2Fexcel-spreadsheetlight-csharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/karenpayneoregon","download_url":"https://codeload.github.com/karenpayneoregon/excel-spreadsheetlight-csharp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2Fexcel-spreadsheetlight-csharp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268370083,"owners_count":24239762,"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-02T02:00:12.353Z","response_time":74,"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":["csharp-core","excel","netcore","spreadsheetlight"],"created_at":"2024-11-30T19:19:25.085Z","updated_at":"2025-08-02T10:06:31.862Z","avatar_url":"https://github.com/karenpayneoregon.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Learn how to work with basic Excel operations in C#\n\n![Title](assets/Title.png)\n\nFor the majority of code samples they can be used cross-platform.\n\n![Title1](assets/Title1.png)\n\n## History\n\n- 2022 - Initial commit\n- 2024 - Updated majority of projects to .NET 9\n\n## Stuck on automation\n\nFor ages coders and developers alike believe that when working with Excel that Excel automation is the best way but there are many issues while when working with .xlsx libraries like GemBox, Aspose cells and others solve these problems. \n\nProblem for those on a shoe-string budget is these libraries are out of reach cost-wise. So this repository I picked one of many free libraries, [SpreadSheetLight](https://spreadsheetlight.com/) and [EEPlus](https://www.epplussoftware.com/en) ([license](https://www.epplussoftware.com/en/Home/LgplToPolyform)) to show how to perform common operations for Excel.\n\nUsing Excel automation to create and Excel file (not my code)\n\n```csharp\nusing Microsoft.Office.Interop.Excel;\nusing System.Reflection;\n\nnamespace ConsoleApplication1\n{\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            Application xl = null;\n            _Workbook wb = null;\n\n            // Option 1\n            xl = new Application();\n            xl.Visible = true;\n            wb = (_Workbook)(xl.Workbooks.Add(XlWBATemplate.xlWBATWorksheet));\n\n            // Option 2\n            xl = new Application();\n            xl.SheetsInNewWorkbook = 1;\n            xl.Visible = true;\n            wb = (_Workbook)(xl.Workbooks.Add(Missing.Value));\n\n        }\n    }\n}\n```\n\n# Moving to Open XML\n\n**With SpreadSheetLight**\n\n```csharp\npublic bool CreateNewFile(string pFileName)\n{\n    using SLDocument document = new();\n    document.SaveAs(pFileName);\n    return true;\n}\n```\n\nOne extra line to rename the default worksheet\n\n```csharp\npublic bool CreateNewFile(string pFileName, string pSheetName)\n{\n    using SLDocument document = new();\n    document.RenameWorksheet(\"Sheet1\", pSheetName);\n    document.SaveAs(pFileName);\n    return true;\n}\n```\n\n# EPPlus\n\nCreate a new file\n\n```csharp\npublic static void CreateNewFile()\n{\n    var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _excelBaseFolder, \"NewFile.xlsx\");\n    using var package = new ExcelPackage();\n    var worksheet = package.Workbook.Worksheets.Add(\"FirstSheet\");\n    package.SaveAs(filePath);\n}\n```\n\n\n# Notes\n\nPersonally my choice is `GemBox.SpreadSheet` and `Asose.Cells` which are not cheap but well worth the cost if a developer is doing a lot of Excel work. `EPPlus` is one to select if on a shoe-string budget and SpreadSheetLight for no budget.\n\n- Some examples use `Entity Framework Core`\n- One example uses `OleDb`.\n  - [OleDb](https://docs.microsoft.com/en-us/office/vba/api/excel.oledbconnection) is limiting in many ways e.g. no formatting and prone to issues with data types.\n- Most examples use SpreadSheetLight and EEPlus, free Excel library\n  - EPPlus is thread safe\n  - SpreadSheetLight is not thread safe\n- There is one Excel automation code sample, best to avoid automation as it can have issues with versioning, server side use and is not cross-platform.\n- When a database is used the project incudes a script to create the database.\n- Code written in Microsoft Visual Studio 2019, .NET Core 5, C#9 and will work in Microsoft Visual Studio 2022, .NET Core 6.\n\n## ExcelMapper\n\nSee the following [repository](https://github.com/karenpayneoregon/ExcelMapperSamples) which has some cool code samples.\n\n### Provided Samples\n\n:heavy_check_mark: See [Tests.cs](https://github.com/mganss/ExcelMapper/blob/master/ExcelMapper.Tests/Tests.cs#L3118) in ExcelMapper repository for more examples.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarenpayneoregon%2Fexcel-spreadsheetlight-csharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarenpayneoregon%2Fexcel-spreadsheetlight-csharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarenpayneoregon%2Fexcel-spreadsheetlight-csharp/lists"}