jfYu.Core.Office
8.0.6
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
.NET Framework 4.6.2
This package targets .NET Framework 4.6.2. The package is compatible with this framework or higher.
dotnet add package jfYu.Core.Office --version 8.0.6
NuGet\Install-Package jfYu.Core.Office -Version 8.0.6
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="jfYu.Core.Office" Version="8.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add jfYu.Core.Office --version 8.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: jfYu.Core.Office, 8.0.6"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install jfYu.Core.Office as a Cake Addin #addin nuget:?package=jfYu.Core.Office&version=8.0.6 // Install jfYu.Core.Office as a Cake Tool #tool nuget:?package=jfYu.Core.Office&version=8.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
<a href="#Office">Office</a>
1、支持导出、导入、自由操作Excel。
2、数据源支持List,Datatable、IQueryable、DbDataReader。
3、自动识别表头,如带Model的导出,并且Model字段标记有DisplayName则自动识别为表头,也可自行设置表头。
4、使用SXSSF导出方式,降低内存占用量。支持海量数据导出,使用超过100w数据自动分Sheet
Nuget安装
Install-Package jfYu.Core.Excel
使用
Excel:
//IOC注入
builder.Services.AddJfYuExcel();
//list导出
var source = new List<ExcelTest>();
source.Add(new ExcelTest() { name = "A", age = 18, Address = "地址1" });
source.Add(new ExcelTest() { name = "B", age = 19, Address = "地址2" });
source.Add(new ExcelTest() { name = "C", age = 20, Address = "地址3" });
excel.ToExcel(source, "exceltest/source.xlsx");
//datatable
var dt = new DataTable();
dt.Columns.Add("id");
dt.Columns.Add("name");
dt.Columns.Add("sex");
dt.Columns.Add("age");
dt.Rows.Add("1", "王", "男", "12");
dt.Rows.Add("2", "wang", "男", "1200000");
dt.Rows.Add("3", "大的洼地", "女", "12");
dt.Rows.Add("4", "dwadwadwad", "1", "12");
dt.Rows.Add("5", "13213213", "0", "1465452");
excel.ToExcel(dt, "exceltest/dtwoh.xlsx");
//DbDataReader
using var conn = new SqliteConnection(datasource);
conn.Open();
sql = "SELECT * FROM test";
cmd.CommandText = sql;
var reader = cmd.ExecuteReader();
excel.ToExcel(reader, "exceltest/dtreader.xlsx", dir);
excel.ToExcel<ExcelTest>(reader, "exceltest/reader.xlsx");//带model
//自由操作Excel
var workbook = excel.CreateWorkbook();
workbook.CreateSheetWithTitles<ExcelTest>();
var dir = new Dictionary<string, string>
{
{ "Age", "年龄" }
};
workbook.CreateSheetWithTitles(dir);
workbook.Save(workbook, "exceltest/new.xlsx");
//excel导入
var dtsourceH = excel.ToDataTable("exceltest/tmp2.xlsx", 0, 1);
var list = excel.GetList<ExcelTest>("exceltest/ImportList.xlsx");
Word:
builder.Services.AddJfYuWord();
var x = new System.Collections.Generic.Dictionary<string, object>
{
{ "x", "测试哦" }
};
var doc = _jfYuWord.GenerateWord();
var paragraph = doc.CreateParagraph();
paragraph.Alignment = ParagraphAlignment.CENTER; //字体居中
var run = paragraph.CreateRun();
run.IsBold = true;
run.SetText("${x}测试测试${y}");
run.FontSize = 28;
run.SetFontFamily("黑体", FontCharRange.None); //设置黑体
paragraph.SpacingBeforeLines = 20;//上方距离
paragraph.SpacingAfterLines = 20;//下方距离
Directory.CreateDirectory("doctest");
FileStream fs = new("doctest/1.docx", FileMode.Create);
doc.Write(fs);
fs.Close();
x.Add("y", "xxx天秤");
_jfYuWord.GenerateWordByTemplate("doctest/1.docx", x, "doctest/2.docx");
Assert.True(File.Exists("doctest/2.docx"));
var fst = File.Open("doctest/2.docx", FileMode.Open);
Assert.True(fst.Length > 0);
fst.Close();
Directory.Delete("doctest", true);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.6.2
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- NPOI (>= 2.7.1)
- System.Text.Encoding.CodePages (>= 8.0.0)
-
.NETStandard 2.0
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- NPOI (>= 2.7.1)
- System.Text.Encoding.CodePages (>= 8.0.0)
-
.NETStandard 2.1
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- NPOI (>= 2.7.1)
- System.Text.Encoding.CodePages (>= 8.0.0)
-
net6.0
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- NPOI (>= 2.7.1)
- System.Text.Encoding.CodePages (>= 8.0.0)
-
net8.0
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- NPOI (>= 2.7.1)
- System.Text.Encoding.CodePages (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.