{"id":27232050,"url":"https://github.com/codespilot/powersheet","last_synced_at":"2025-04-10T13:45:52.433Z","repository":{"id":47484385,"uuid":"386469691","full_name":"Codespilot/Powersheet","owner":"Codespilot","description":"Powersheet是一个基于.net standard 2.1开发的跨平台的Excel数据导入、导出类库。","archived":false,"fork":false,"pushed_at":"2022-10-10T01:44:02.000Z","size":237,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-27T06:36:59.691Z","etag":null,"topics":[],"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/Codespilot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-16T01:17:18.000Z","updated_at":"2023-11-22T11:23:46.000Z","dependencies_parsed_at":"2023-01-19T23:35:02.443Z","dependency_job_id":null,"html_url":"https://github.com/Codespilot/Powersheet","commit_stats":null,"previous_names":["realzhaorong/powersheet"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codespilot%2FPowersheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codespilot%2FPowersheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codespilot%2FPowersheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codespilot%2FPowersheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Codespilot","download_url":"https://codeload.github.com/Codespilot/Powersheet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248226838,"owners_count":21068297,"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":"2025-04-10T13:45:51.485Z","updated_at":"2025-04-10T13:45:52.420Z","avatar_url":"https://github.com/Codespilot.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Powersheet简介\nPowersheet是一个基于.net standard 2.1开发的跨平台的Excel数据导入、导出类库。配置灵活，使用方便。支持DataTable、List\u003cT\u003e作为数据源。支持侵入和非侵入两种字段映射配置方式。\n\n### 功能\n1. 从Excel文件或流提取数据并转换为DataTable或对象集合；\n2. 将DataTable或对象集合的数据写入到Excel文件；\n\n### 特色\n1. 基于.net standard 2.1开发，支持跨平台使用；\n2. 轻量，不需要安装 Microsoft Office、COM+组件，体积小；\n3. 提供nuget包，安装方便快捷；\n4. 使用简单，对象属性和Excel列映射配置灵活，支持侵入式（使用属性Attribute）和非侵入（传入配置参数）两种方式；\n5. 易于扩展；\n\n## Nuget包\n|包名称|版本|描述|\n|--|--|--|\n|Powersheet.Core|[![NuGet](https://img.shields.io/nuget/v/Powersheet.Core.svg?label=nuget)](https://www.nuget.org/packages/Powersheet.Core/)|Powersheet核心类库，包含接口定义，公共方法实现以及其他需要用到的类。|\n|Powersheet.Npoi|[![NuGet](https://img.shields.io/nuget/v/Powersheet.Npoi.svg?label=nuget)](https://www.nuget.org/packages/Powersheet.Npoi/)|Powersheet的NPOI实现|\n|Powersheet.Epplus|[![NuGet](https://img.shields.io/nuget/v/Powersheet.Epplus.svg?label=nuget)](https://www.nuget.org/packages/Powersheet.Epplus/)|Powersheet的EPPLUS实现|\n\n## 如何使用\n\n### 安装Powersheet\n\n\u003e Powersheet.Epplus或Powersheet.Npoi根据需要安装其一即可。如果需要自行实现表格读取，仅需要引入Powersheet.Core。\n\n命令行\n```shell\ndotnet add package Powersheet.Core \n\ndotnet add package Powersheet.Npoi \n\ndotnet add package Powersheet.Epplus \n```\n\nScript \u0026 Interactive\n```shell\n#r \"nuget: Powersheet.Core\"\n\n#r \"nuget: Powersheet.Npoi\"\n\n#r \"nuget: Powersheet.Epplus\"\n```\n\n### 配置依赖注入\n\n使用Microsoft.Extensions.DependencyInjection\n```csharp\nservices.AddSingleton\u003cISheetWrapper, SheetWrapper\u003e();\n```\n\n使用Autofac\n```csharp\nbuilder.RegisterType\u003cSheetWrapper\u003e().As\u003cISheetWrapper\u003e().SingleInstance();\n```\n\n如果使用EPPLUS版本的实现，还需要在appSettings.json文件增加一个配置节点\n```json\n\"EPPlus\": {\n    \"ExcelPackage\": {\n      \"LicenseContext\": \"NonCommercial\"\n    }\n  }\n```\n### 接口定义\n\n#### 读取表格内容到DataTable\n\n```csharp\nTask\u003cDataTable\u003e ReadToDataTableAsync(string file, SheetReadOptions options, int sheetIndex, CancellationToken cancellationToken);\n```\n\u003e 1. file - 文件路径\n\u003e 2. options - 配置选项\n\u003e 3. sheetIndex - 表格位置索引，起始值为0\n\n```csharp\nTask\u003cDataTable\u003e ReadToDataTableAsync(string file, SheetReadOptions options, string sheetName, CancellationToken cancellationToken);\n```\n\u003e 1. file - 文件路径\n\u003e 2. options - 配置选项\n\u003e 3. sheetName - 表格名称，不指定取第一个\n```csharp\nTask\u003cDataTable\u003e ReadToDataTableAsync(Stream stream, SheetReadOptions options, int sheetIndex, CancellationToken cancellationToken);\n```\n\u003e 1. stream - 文件流\n\u003e 2. options - 配置选项\n\u003e 3. sheetIndex - 表格位置索引，起始值为0\n```csharp\nTask\u003cDataTable\u003e ReadToDataTableAsync(Stream stream, SheetReadOptions options, string sheetName, CancellationToken cancellationToken);\n```\n\u003e 1. stream - 文件流\n\u003e 2. options - 配置选项\n\u003e 3. sheetName - 表格名称，不指定取第一个\n\n#### 读取表格内容到对象集合\n```csharp\nTask\u003cList\u003cT\u003e\u003e ReadToListAsync\u003cT\u003e(string file, SheetReadOptions options, int sheetIndex, CancellationToken cancellationToken);\n```\n\u003e 1. file - 文件路径\n\u003e 2. options - 配置选项\n\u003e 3. sheetIndex - 表格位置索引，起始值为0\n\u003e 4. T - 结果对象类型，必须是类且包含公开的无参构造器\n\n```csharp\nTask\u003cList\u003cT\u003e\u003e ReadToListAsync\u003cT\u003e(string file, SheetReadOptions options, string sheetName, CancellationToken cancellationToken);\n```\n\u003e 1. file - 文件路径\n\u003e 2. options - 配置选项\n\u003e 3. sheetName - 表格名称，不指定取第一个\n\u003e 4. T - 结果对象类型，必须是类且包含公开的无参构造器\n\n```csharp\nTask\u003cList\u003cT\u003e\u003e ReadToListAsync\u003cT\u003e(Stream stream, SheetReadOptions options, int sheetIndex, CancellationToken cancellationToken);\n```\n\u003e 1. stream - 文件流\n\u003e 2. options - 配置选项\n\u003e 3. sheetIndex - 表格位置索引，起始值为0\n\u003e 4. T - 结果对象类型，必须是类且包含公开的无参构造器\n\n```csharp\nTask\u003cList\u003cT\u003e\u003e ReadToListAsync\u003cT\u003e(Stream stream, SheetReadOptions options, string sheetName, CancellationToken cancellationToken);\n```\n\u003e 1. stream - 文件流\n\u003e 2. options - 配置选项\n\u003e 3. sheetName - 表格名称，不指定取第一个\n\u003e 4. T - 结果对象类型，必须是类且包含公开的无参构造器\n\n#### 读取指定单列数据到集合\n```csharp\nTask\u003cList\u003cT\u003e\u003e ReadToListAsync\u003cT\u003e(string file, int firstRowNumber, int columnNumber, int sheetIndex, Func\u003cobject, CultureInfo, T\u003e valueConvert, CancellationToken cancellationToken);\n```\n\u003e 1. file - 文件路径\n\u003e 2. firstRowNumber - 起始行号，从1开始\n\u003e 3. columnNumber - 列号，起始值为1\n\u003e 4. sheetIndex - 表格位置索引，起始值为0\n\u003e 5. valueConvert - 值转换方法\n\n```csharp\nTask\u003cList\u003cT\u003e\u003e ReadToListAsync\u003cT\u003e(string file, int firstRowNumber, int columnNumber, string sheetName, Func\u003cobject, CultureInfo, T\u003e valueConvert, CancellationToken cancellationToken);\n```\n\u003e 1. file - 文件路径\n\u003e 2. firstRowNumber - 起始行号，起始值为1\n\u003e 3. columnNumber - 列号，起始值为1\n\u003e 4. sheetName - 表格名称，不指定取第一个\n\u003e 5. valueConvert - 值转换方法\n\n```csharp\nTask\u003cList\u003cT\u003e\u003e ReadToListAsync\u003cT\u003e(Stream stream, int firstRowNumber, int columnNumber, int sheetIndex, Func\u003cobject,  CultureInfo, T\u003e valueConvert, CancellationToken cancellationToken);\n```\n\u003e 1. stream - 文件流\n\u003e 2. firstRowNumber - 起始行号，起始值为1\n\u003e 3. columnNumber - 列号，起始值为1\n\u003e 4. sheetIndex - 表格位置索引，起始值为0\n\u003e 5. valueConvert - 值转换方法\n\n```csharp\nTask\u003cList\u003cT\u003e\u003e ReadToListAsync\u003cT\u003e(Stream stream, int firstRowNumber, int columnNumber, string sheetName, Func\u003cobject, CultureInfo, T\u003e valueConvert, CancellationToken cancellationToken);\n```\n\u003e 1. stream - 文件流\n\u003e 2. firstRowNumber - 起始行号，起始值为1\n\u003e 3. columnNumber - 列号，起始值为1\n\u003e 4. sheetName - 表格名称，不指定取第一个\n\u003e 5. valueConvert - 值转换方法\n\n## 协议\n\n本项目采用 Apache-2.0 协议，可查看 [LICENSE](https://github.com/realzhaorong/Powersheet/blob/master/LICENSE) 了解更详细内容。\n\n## 联系我们\n\n如果您需要向我们反馈 Bug、提供产品意见，可以创建一个 [Github issue](https://github.com/realzhaorong/Powersheet/issues) 联系我们，非常感谢！\n\n---\n\n[![JetBrains](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)](https://www.jetbrains.com/)\n\nThanks to [JetBrains](https://www.jetbrains.com/) for supporting the project through [All Products Packs](https://www.jetbrains.com/products.html) within their [Free Open Source License](https://www.jetbrains.com/community/opensource) program.\n\n---\n![Alt](https://repobeats.axiom.co/api/embed/eff3327d99d2da5a87ff59600720befd793cff06.svg \"Repobeats analytics image\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodespilot%2Fpowersheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodespilot%2Fpowersheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodespilot%2Fpowersheet/lists"}