增加循环检测按钮

This commit is contained in:
uu
2025-06-12 15:03:32 +08:00
parent 86a10f3cc7
commit 011a93a777
240 changed files with 298278 additions and 25 deletions

BIN
packages/EPPlus.5.0.3/.signature.p7s vendored Normal file

Binary file not shown.

BIN
packages/EPPlus.5.0.3/EPPlus.5.0.3.nupkg vendored Normal file

Binary file not shown.

BIN
packages/EPPlus.5.0.3/EPPlusLogo.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

49034
packages/EPPlus.5.0.3/lib/net35/EPPlus.xml vendored Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

49034
packages/EPPlus.5.0.3/lib/net40/EPPlus.xml vendored Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

49297
packages/EPPlus.5.0.3/lib/net45/EPPlus.xml vendored Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

131
packages/EPPlus.5.0.3/license.md vendored Normal file
View File

@@ -0,0 +1,131 @@
# Polyform Noncommercial License 1.0.0
<https://polyformproject.org/licenses/noncommercial/1.0.0>
## Acceptance
In order to get any license under these terms, you must agree
to them as both strict obligations and conditions to all
your licenses.
## Copyright License
The licensor grants you a copyright license for the
software to do everything you might do with the software
that would otherwise infringe the licensor's copyright
in it for any permitted purpose. However, you may
only distribute the software according to [Distribution
License](#distribution-license) and make changes or new works
based on the software according to [Changes and New Works
License](#changes-and-new-works-license).
## Distribution License
The licensor grants you an additional copyright license
to distribute copies of the software. Your license
to distribute covers distributing the software with
changes and new works permitted by [Changes and New Works
License](#changes-and-new-works-license).
## Notices
You must ensure that anyone who gets a copy of any part of
the software from you also gets a copy of these terms or the
URL for them above, as well as copies of any plain-text lines
beginning with `Required Notice:` that the licensor provided
with the software. For example:
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
## Changes and New Works License
The licensor grants you an additional copyright license to
make changes and new works based on the software for any
permitted purpose.
## Patent License
The licensor grants you a patent license for the software that
covers patent claims the licensor can license, or becomes able
to license, that you would infringe by using the software.
## Noncommercial Purposes
Any noncommercial purpose is a permitted purpose.
## Personal Uses
Personal use for research, experiment, and testing for
the benefit of public knowledge, personal study, private
entertainment, hobby projects, amateur pursuits, or religious
observance, without any anticipated commercial application,
is use for a permitted purpose.
## Noncommercial Organizations
Use by any charitable organization, educational institution,
public research organization, public safety or health
organization, environmental protection organization,
or government institution is use for a permitted purpose
regardless of the source of funding or obligations resulting
from the funding.
## Fair Use
You may have "fair use" rights for the software under the
law. These terms do not limit them.
## No Other Rights
These terms do not allow you to sublicense or transfer any of
your licenses to anyone else, or prevent the licensor from
granting licenses to anyone else. These terms do not imply
any other licenses.
## Patent Defense
If you make any written claim that the software infringes or
contributes to infringement of any patent, your patent license
for the software granted under these terms ends immediately. If
your company makes such a claim, your patent license ends
immediately for work on behalf of your company.
## Violations
The first time you are notified in writing that you have
violated any of these terms, or done anything with the software
not covered by your licenses, your licenses can nonetheless
continue if you come into full compliance with these terms,
and take practical steps to correct past violations, within
32 days of receiving notice. Otherwise, all your licenses
end immediately.
## No Liability
***As far as the law allows, the software comes as is, without
any warranty or condition, and the licensor will not be liable
to you for any damages arising out of these terms or the use
or nature of the software, under any kind of legal claim.***
## Definitions
The **licensor** is the individual or entity offering these
terms, and the **software** is the software the licensor makes
available under these terms.
**You** refers to the individual or entity agreeing to these
terms.
**Your company** is any legal entity, sole proprietorship,
or other kind of organization that you work for, plus all
organizations that have control over, are under the control of,
or are under common control with that organization. **Control**
means ownership of substantially all the assets of an entity,
or the power to direct its management and policies by vote,
contract, or otherwise. Control can be direct or indirect.
**Your licenses** are all the licenses granted to you for the
software under these terms.
**Use** means anything you do with the software requiring one
of your licenses.

69
packages/EPPlus.5.0.3/readme.txt vendored Normal file
View File

@@ -0,0 +1,69 @@
# EPPlus 5
## Announcement: new license model from version 5
EPPlus has from this new major version changed license from LGPL to [Polyform Noncommercial 1.0.0](https://polyformproject.org/licenses/noncommercial/1.0.0/).
With the new license EPPlus is still free to use in some cases, but will require a commercial license to be used in a commercial business.
This is explained in more detail [here](https://www.epplussoftware.com/Home/LgplToPolyform).
Commercial licenses, which includes support, can be purchased at (https://www.epplussoftware.com/).
The source code of EPPlus has moved to a [new github repository](https://github.com/EPPlusSoftware/EPPlus)
## LicenseContext parameter must be set
With the license change EPPlus has a new parameter that needs to be configured. If the LicenseContext is not set, EPPlus will throw a LicenseException (only in debug mode).
This is a simple configuration that can be set in a few alternative ways:
### 1. Via code
```csharp
// If you are a commercial business and have
// purchased commercial licenses use the static property
// LicenseContext of the ExcelPackage class :
ExcelPackage.LicenseContext = LicenseContext.Commercial;
// If you use EPPlus in a noncommercial context
// according to the Polyform Noncommercial license:
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using(var package = new ExcelPackage(new FileInfo("MyWorkbook.xlsx")))
{
}
```
### 2. Via appSettings.json
```json
{
{
"EPPlus": {
"ExcelPackage": {
"LicenseContext": "Commercial" //The license context used
}
}
}
}
```
### 3. Via app/web.config
```xml
<appSettings>
<!--The license context used-->
<add key="EPPlus:ExcelPackage.LicenseContext" value="NonCommercial" />
</appSettings>
```
### 4. Set the environment variable 'EPPlusLicenseContext'
This might be the easiest way of configuring this. Just as above, set the variable to Commercial or NonCommercial depending on your usage.
**Important!** The environment variable should be set at the user level.
## New features in EPPlus 5
EPPlus 5 comes with a set of new features, see (https://www.epplussoftware.com/Developers/Features)
## Breaking Changes
* The default behavior for the Worksheet collection base in .NET Framework has changed from 1 to 0. This is the same default behavior as in .NET core today.
* Pictures have changed the behavior as the oneCellAnchor tag is used instead of the twoCellAnchor tag with the editAs="oneCell".
* ...and more, see https://epplussoftware.com/docs/5.0/articles/breakingchanges.html
## Improved documentation
EPPlus 5 has new, separate sample projects for [.NET Core](https://github.com/EPPlusSoftware/EPPlus.Sample.NetCore) and [.NET Framework](https://github.com/EPPlusSoftware/EPPlus.Sample.NetFramework) respectively.
There is also an updated [developer wiki](https://github.com/EPPlusSoftware/EPPlus/wiki). The work with improving the documentation will continue, feedback is highly appreciated!

Binary file not shown.

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 Run2948
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,149 @@
# OfficeOpenXml.Extension.AspNetCore
OfficeOpenXml.Extension.AspNetCore 是一个基于 OfficeOpenXml 拓展,它依赖于 [EPPlus](https://www.nuget.org/packages/EPPlus/5.0.3),用于根据模板输出 Excel。
**注意:** 由于 Excel 2003 版本 和 2007 之后版本文件结构的差异性,当前扩展无法同时兼容两种模式,仅支持 *.xlsx 文件!!!
## 快速使用
### 1. 安装组件
* [OfficeOpenXml.Extension.AspNetCore](https://www.nuget.org/packages/OfficeOpenXml.Extension.AspNetCore)
``` bash
dotnet add package OfficeOpenXml.Extension.AspNetCore
```
### 2.使用组件
#### 2.1 读取 Excel 模板, 导入数据
* 准备Excel模板
* [Projects.xlsx](./samples/OfficeOpenXmlSample/wwwroot/templates/Projects.xlsx)
* 定义接收对象
```csharp
[Worksheet(Index = 1, HasHeader = false)]
public class ProjectRow
{
[Column(Number = 1)]
public int Id { get; set; }
[Column(Number = 2)]
public string Name { get; set; }
[Column(Number = 3)]
public string Description { get; set; }
}
```
+ Worksheet - 表格属性,其中 `Index` 对应表格的索引(从 0 开始),`HasHeader` 对应当前表格是否包含表头
+ Column - 单元格属性,其中 `Number` 对应单元格的列
* 读取 Excel 信息
```csharp
[HttpGet("projects", Name = "Projects")]
public IEnumerable<ProjectRow> GetProjects()
{
var excelFilePath = Path.Combine(_wwwroot, "templates", "Projects.xlsx");
var fileStream = new System.IO.FileStream(excelFilePath, FileMode.Open);
using var excelPackage = new ExcelPackage(fileStream);
return excelPackage.ParseWorksheet<ProjectRow>().ToList();
}
```
* 最终结果展示
```json
[
{
"id": 1,
"name": "MyHRW",
"description": "Case Management Tool"
},
{
"id": 2,
"name": "PEX",
"description": "Global Payroll Exchange"
}
]
```
#### 2.2 读取 Excel 模板,导出数据
* 准备Excel模板
* [tpl.xlsx](./samples/OfficeOpenXmlSample/wwwroot/templates/tpl.xlsx)
* 读取模板文件
```csharp
var excelFilePath = Path.Combine(_wwwroot, "templates", "tpl.xlsx");
var fileStream = new System.IO.FileStream(excelFilePath, FileMode.Open);
using var excelPackage = new ExcelPackage(fileStream);
var workBook = excelPackage.Workbook;
```
* 构造填充对象
```csharp
Dictionary<string, IEnumerable<string>> _marketLists = new()
{
{ "水果", new string[] { "桃子", "李子", "香蕉", "梨" } },
{ "蔬菜", new string[] { "青菜", "土豆", "黄瓜", "啤酒" } }
};
//构造model
var model = new
{
ProjectName = "灰太狼",
Name = "Jeff",
CreatedAt = DateTime.Now,
BuyerName = "Bill",
Cates = _marketLists.Select(m => new
{
Name = m.Key,
Items = m.Value.Select(n => new
{
Name = n,
Price = (decimal)random.Next(1, 100),
Amount = random.Next(1, 100)
})
})
};
```
* 填充数据对象
```csharp
// 下面的FillModel就是 OfficeOpenXml.Extension.AspNetCore 提供的拓展方法
workBook.Worksheets.First().FillModel(model);
```
* 导出模板文件
```csharp
string fileName = "Lists_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
string exportFilePath = Path.Combine(_wwwroot, "outputs", fileName);
var exportFile = new FileInfo(exportFilePath);
excelPackage.SaveAs(exportFile);
return File(exportFile.OpenRead(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName);
```
#### 2.3 其他功能辅助说明
* 输出内容目前仅支持基础的变量、成员,不支持方法、运算等高级特性;控制代码目前仅支持 for 循环、嵌套 for 循环以及索引使用索引时需要注意索引计数从1开始因为excel中通常序号从1开始。
* 输出公式的功能用 @= 开头便于程序识别,解析时会将 @ 去掉,后面的内容对 {...} 进行解释并替换。R[-4]表示相对值-4行R[-1]表示相对值-1行C后面没有 [] 表示当前列。
* 具体细节可以进一步参考案例代码:
* [ConsoleApp1](./samples/net45/Program.cs)
* [OfficeOpenXmlSample](./samples/OfficeOpenXmlSample/Controllers/ExcelController.cs)
### 鸣谢
* [OfficeOpenXml.Entends 根据模板导出Excel](https://www.cnblogs.com/mhsg/p/7125112.html)
* [OfficeOpenXml.Extensions EPPlus Extensions](https://github.com/olivierl/OfficeOpenXml.Extensions)

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB