diff --git a/README.md b/README.md
index bb98cea0b2c98a9cfb2e99b8f50213a8ba06e644..bf2ee53be88500f25bb8c51bf6dd1db6d930189a 100644
--- a/README.md
+++ b/README.md
@@ -1,474 +1,40 @@
-
+# miniword中添加html支持
----
+## 说明
-
+在**miniword**项目中引用**htmlToOpenXml**添加html支持
----
+## 环境
-
+**.Net Framework 4.6.2**, **.NET Standard 2.0**
----
+## 相关依赖
-## Introduction
+**miniword**:https://gitee.com/dotnetchina/MiniWord
-MiniWord is an easy and effective .NET Word Template library.
+**htmlToOpenXml**:https://github.com/onizet/html2openxml
-
+## 使用手册
+1. 引入MiniWordWithHtml.dll
+ https://gitee.com/tangdou89/MiniWord/releases
-## Getting Started
+2. nuget安装依赖
-### Installation
+ ```cmd
+ dotnet add package DocumentFormat.OpenXml --version 3.4.1
+ dotnet add package HtmlToOpenXml --version 3.3.1
+ dotnet add package System.Text.Encoding.CodePages --version 10.0.3
+ ```
-- nuget link : https://www.nuget.org/packages/MiniWord
+3. html解析
-### Quick Start
+ ```c#
+ new MiniWordHtml
+ {
+ HtmlText = File.ReadAllText(@"TestData\sample2.html")
+ }
+ ```
-Template follow "WHAT you see is what you get" design,and the template tag styles are completely preserved.
-```csharp
-var value = new Dictionary(){["title"] = "Hello MiniWord"};
-MiniSoftware.MiniWord.SaveAsByTemplate(outputPath, templatePath, value);
-```
-
-
-
-### Input, Output
-
-- Input support file path, byte[]
-- Output support file path, byte[], stream
-
-```csharp
-SaveAsByTemplate(string path, string templatePath, Dictionary value)
-SaveAsByTemplate(string path, byte[] templateBytes, Dictionary value)
-SaveAsByTemplate(this Stream stream, string templatePath, Dictionary value)
-SaveAsByTemplate(this Stream stream, byte[] templateBytes, Dictionary value)
-```
-
-
-
-## Tags
-
-MiniWord template format string like Vue, React `{{tag}}`,users only need to make sure tag and value parameter key same then system will replace them automatically.
-
-### Text
-
-```csharp
-{{tag}}
-```
-
-##### Example
-
-```csharp
-var value = new Dictionary()
-{
- ["Name"] = "Jack",
- ["Department"] = "IT Department",
- ["Purpose"] = "Shanghai site needs a new system to control HR system.",
- ["StartDate"] = DateTime.Parse("2022-09-07 08:30:00"),
- ["EndDate"] = DateTime.Parse("2022-09-15 15:30:00"),
- ["Approved"] = true,
- ["Total_Amount"] = 123456,
-};
-MiniWord.SaveAsByTemplate(path, templatePath, value);
-```
-
-##### Template
-
-
-
-##### Result
-
-
-
-### Image
-
-Value type is `MiniWordPicture`
-
-##### Example
-
-```csharp
-var value = new Dictionary()
-{
- ["Logo"] = new MiniWordPicture() { Path= PathHelper.GetFile("DemoLogo.png"), Width= 180, Height= 180 }
-};
-MiniWord.SaveAsByTemplate(path, templatePath, value);
-```
-
-
-
-##### Template
-
-
-
-##### Result
-
-
-
-### List
-
-tag value is `string[]` or `IList` type
-
-##### Example
-
-```csharp
-var value = new Dictionary()
-{
- ["managers"] = new[] { "Jack" ,"Alan"},
- ["employees"] = new[] { "Mike" ,"Henry"},
-};
-MiniWord.SaveAsByTemplate(path, templatePath, value);
-```
-
-Template
-
-
-
-##### Result
-
-
-
-### Table
-
-Tag value is `IEmerable>` type
-
-##### Example
-
-```csharp
-var value = new Dictionary()
-{
- ["TripHs"] = new List>
- {
- new Dictionary
- {
- { "sDate",DateTime.Parse("2022-09-08 08:30:00")},
- { "eDate",DateTime.Parse("2022-09-08 15:00:00")},
- { "How","Discussion requirement part1"},
- { "Photo",new MiniWordPicture() { Path = PathHelper.GetFile("DemoExpenseMeeting02.png"), Width = 160, Height = 90 }},
- },
- new Dictionary
- {
- { "sDate",DateTime.Parse("2022-09-09 08:30:00")},
- { "eDate",DateTime.Parse("2022-09-09 17:00:00")},
- { "How","Discussion requirement part2 and development"},
- { "Photo",new MiniWordPicture() { Path = PathHelper.GetFile("DemoExpenseMeeting01.png"), Width = 160, Height = 90 }},
- },
- }
-};
-MiniWord.SaveAsByTemplate(path, templatePath, value);
-```
-
-##### Template
-
-
-
-
-##### Result
-
-
-
-### List inside list
-
-Tag value is `IEnumerable` type. Adding `{{foreach` and `endforeach}}` tags to template is required.
-
-##### Example
-
-```csharp
-var value = new Dictionary()
-{
- ["TripHs"] = new List>
- {
- new Dictionary
- {
- { "sDate", DateTime.Parse("2022-09-08 08:30:00") },
- { "eDate", DateTime.Parse("2022-09-08 15:00:00") },
- { "How", "Discussion requirement part1" },
- {
- "Details", new List()
- {
- new MiniWordForeach()
- {
- Value = new Dictionary()
- {
- {"Text", "Air"},
- {"Value", "Airplane"}
- },
- Separator = " | "
- },
- new MiniWordForeach()
- {
- Value = new Dictionary()
- {
- {"Text", "Parking"},
- {"Value", "Car"}
- },
- Separator = " / "
- }
- }
- }
- }
- }
-};
-MiniWord.SaveAsByTemplate(path, templatePath, value);
-```
-
-##### Template
-
-
-
-
-
-##### Result
-
-
-
-
-
-### If statement inside template
-
-For multip paragraph, use @if and @endif tags.
-For single paragraph and inside foreach, use `{{if` and `endif}}` tags to template is required.
-
-##### Example
-
-```csharp
-var value = new Dictionary()
-{
- ["Name"] = new List(){
- new MiniWordHyperLink(){
- Url = "https://google.com",
- Text = "測試連結22!!"
- },
- new MiniWordHyperLink(){
- Url = "https://google1.com",
- Text = "測試連結11!!"
- }
- },
- ["Company_Name"] = "MiniSofteware",
- ["CreateDate"] = new DateTime(2021, 01, 01),
- ["VIP"] = true,
- ["Points"] = 123,
- ["APP"] = "Demo APP",
-};
-MiniWord.SaveAsByTemplate(path, templatePath, value);
-```
-
-##### Template For Multi Paragraph
-
-
-
-##### Result Of Multi Paragraph
-
-
-
-##### Template For Single Paragraph
-
-
-
-##### Result Of Single Paragraph
-
-
-
-### ColorText
-
-##### Example
-
-```csharp
-var value = new
-{
- Company_Name = new MiniWordColorText { Text = "MiniSofteware", FontColor = "#eb70AB", },
- Name = new[] {
- new MiniWordColorText { Text = "Ja", HighlightColor = "#eb70AB" },
- new MiniWordColorText { Text = "ck", HighlightColor = "#a56abe" }
- },
- CreateDate = new MiniWordColorText
- {
- Text = new DateTime(2021, 01, 01).ToString(),
- HighlightColor = "#eb70AB",
- FontColor = "#ffffff",
- },
- VIP = true,
- Points = 123,
- APP = "Demo APP",
-};
-MiniWord.SaveAsByTemplate(path, templatePath, value);
-```
-
-
-## Other
-
-### POCO or dynamic parameter
-
-v0.5.0 support POCO or dynamic parameter
-
-```csharp
-var value = new { title = "Hello MiniWord" };
-MiniWord.SaveAsByTemplate(outputPath, templatePath, value);
-```
-
-### FontColor and HighlightColor
-```csharp
-var value = new
-{
- Company_Name = new MiniWordColorText { Text = "MiniSofteware", FontColor = "#eb70AB" },
- Name = new MiniWordColorText { Text = "Jack", HighlightColor = "#eb70AB" },
- CreateDate = new MiniWordColorText { Text = new DateTime(2021, 01, 01).ToString(), HighlightColor = "#eb70AB", FontColor = "#ffffff" },
- VIP = true,
- Points = 123,
- APP = "Demo APP",
-};
-```
-
-### HyperLink
-
-If value type is `MiniWordHyperLink` system will replace template string by hyperlink.
-
-* Url: HyperLink URI target path
-* Text:Description
-
-```csharp
-var value = new
-{
- ["Name"] = new MiniWordHyperLink(){
- Url = "https://google.com",
- Text = "Test Link!!"
- },
- ["Company_Name"] = "MiniSofteware",
- ["CreateDate"] = new DateTime(2021, 01, 01),
- ["VIP"] = true,
- ["Points"] = 123,
- ["APP"] = "Demo APP",
-};
-MiniWord.SaveAsByTemplate(path, templatePath, value);
-```
-
-
-
-## Examples
-
-
-
-#### ASP.NET Core 3.1 API Export
-
-```cs
-using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Hosting;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Net;
-using MiniSoftware;
-
-public class Program
-{
- public static void Main(string[] args) => CreateHostBuilder(args).Build().Run();
-
- public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup());
-}
-
-public class Startup
-{
- public void ConfigureServices(IServiceCollection services) => services.AddMvc();
- public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
- {
- app.UseStaticFiles();
- app.UseRouting();
- app.UseEndpoints(endpoints =>
- {
- endpoints.MapControllerRoute(
- name: "default",
- pattern: "{controller=api}/{action=Index}/{id?}");
- });
- }
-}
-
-public class ApiController : Controller
-{
- public IActionResult Index()
- {
- return new ContentResult
- {
- ContentType = "text/html",
- StatusCode = (int)HttpStatusCode.OK,
- Content = @"
-DownloadWordFromTemplatePath
-DownloadWordFromTemplateBytes
-"
- };
- }
-
- static Dictionary defaultValue = new Dictionary()
- {
- ["title"] = "FooCompany",
- ["managers"] = new List> {
- new Dictionary{{"name","Jack"},{ "department", "HR" } },
- new Dictionary {{ "name", "Loan"},{ "department", "IT" } }
- },
- ["employees"] = new List> {
- new Dictionary{{ "name", "Wade" },{ "department", "HR" } },
- new Dictionary {{ "name", "Felix" },{ "department", "HR" } },
- new Dictionary{{ "name", "Eric" },{ "department", "IT" } },
- new Dictionary {{ "name", "Keaton" },{ "department", "IT" } }
- }
- };
-
- public IActionResult DownloadWordFromTemplatePath()
- {
- string templatePath = "TestTemplateComplex.docx";
-
- Dictionary value = defaultValue;
-
- MemoryStream memoryStream = new MemoryStream();
- MiniWord.SaveAsByTemplate(memoryStream, templatePath, value);
- memoryStream.Seek(0, SeekOrigin.Begin);
- return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
- {
- FileDownloadName = "demo.docx"
- };
- }
-
- private static Dictionary TemplateBytesCache = new Dictionary();
-
- static ApiController()
- {
- string templatePath = "TestTemplateComplex.docx";
- byte[] bytes = System.IO.File.ReadAllBytes(templatePath);
- TemplateBytesCache.Add(templatePath, bytes);
- }
-
- public IActionResult DownloadWordFromTemplateBytes()
- {
- byte[] bytes = TemplateBytesCache["TestTemplateComplex.docx"];
-
- Dictionary value = defaultValue;
-
- MemoryStream memoryStream = new MemoryStream();
- MiniWord.SaveAsByTemplate(memoryStream, bytes, value);
- memoryStream.Seek(0, SeekOrigin.Begin);
- return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
- {
- FileDownloadName = "demo.docx"
- };
- }
-}
-```
-
-
-
-
-
-
-## Support : [Donate Link](https://miniexcel.github.io/)
diff --git a/README.zh-CN.md b/README.zh-CN.md
deleted file mode 100644
index 5d0e1a28add62d5e56c9cfca1b00a84dd0e4d8bb..0000000000000000000000000000000000000000
--- a/README.zh-CN.md
+++ /dev/null
@@ -1,525 +0,0 @@
-
-
----
-
-
-
----
-
-
- 您的
Star 和
赞助 可以让 MiniWord 走更远
-
-
----
-
-## QQ群(1群) : [813100564](https://qm.qq.com/cgi-bin/qm/qr?k=3OkxuL14sXhJsUimWK8wx_Hf28Wl49QE&jump_from=webapi) / QQ群(2群) : [579033769](https://jq.qq.com/?_wv=1027&k=UxTdB8pR)
-
-----
-
-## 介绍
-
-MiniWord .NET Word模板引擎,藉由Word模板和数据简单、快速生成文件。
-
-
-
-
-
-## Getting Started
-
-### 安装
-
-- nuget link : https://www.nuget.org/packages/MiniWord
-
-### 快速入门
-
-模板遵循“所见即所得”的设计,模板和标签的样式会被完全保留
-
-```csharp
-var value = new Dictionary(){["title"] = "Hello MiniWord"};
-MiniSoftware.MiniWord.SaveAsByTemplate(outputPath, templatePath, value);
-```
-
-
-
-### 输入、输出
-
-- 输入系统支持模版路径或是Byte[]
-- 输出支持文件路径、Byte[]、Stream
-
-```csharp
-SaveAsByTemplate(string path, string templatePath, Dictionary value)
-SaveAsByTemplate(string path, byte[] templateBytes, Dictionary value)
-SaveAsByTemplate(this Stream stream, string templatePath, Dictionary value)
-SaveAsByTemplate(this Stream stream, byte[] templateBytes, Dictionary value)
-```
-
-
-
-## 标签
-
-MiniWord 使用类似 Vue, React 的模版字串 `{{tag}}`,只需要确保 tag 与 value 参数的 key 一样`(大小写敏感)`,系统会自动替换字串。
-
-### 文本
-
-```csharp
-{{tag}}
-```
-
-
-
-##### 代码例子
-
-```csharp
-var value = new Dictionary()
-{
- ["Name"] = "Jack",
- ["Department"] = "IT Department",
- ["Purpose"] = "Shanghai site needs a new system to control HR system.",
- ["StartDate"] = DateTime.Parse("2022-09-07 08:30:00"),
- ["EndDate"] = DateTime.Parse("2022-09-15 15:30:00"),
- ["Approved"] = true,
- ["Total_Amount"] = 123456,
-};
-MiniWord.SaveAsByTemplate(path, templatePath, value);
-```
-
-##### 模版
-
-
-
-##### 导出
-
-
-
-### 图片
-
-标签值为 `MiniWordPicture` 类别
-
-##### 代码例子
-
-```csharp
-var value = new Dictionary()
-{
- ["Logo"] = new MiniWordPicture() { Path= PathHelper.GetFile("DemoLogo.png"), Width= 180, Height= 180 }
-};
-MiniWord.SaveAsByTemplate(path, templatePath, value);
-```
-
-
-
-##### 模版
-
-
-
-##### 导出
-
-
-
-### 列表
-
-标签值为 `string[]` 或是 `IList`类别
-
-##### 代码例子
-
-```csharp
-var value = new Dictionary()
-{
- ["managers"] = new[] { "Jack" ,"Alan"},
- ["employees"] = new[] { "Mike" ,"Henry"},
-};
-MiniWord.SaveAsByTemplate(path, templatePath, value);
-```
-
-##### 模版
-
-
-
-##### 导出
-
-
-
-### 表格
-
-标签值为 `IEmerable>`类别
-
-##### 代码例子
-
-```csharp
-var value = new Dictionary()
-{
- ["TripHs"] = new List>
- {
- new Dictionary
- {
- { "sDate",DateTime.Parse("2022-09-08 08:30:00")},
- { "eDate",DateTime.Parse("2022-09-08 15:00:00")},
- { "How","Discussion requirement part1"},
- { "Photo",new MiniWordPicture() { Path = PathHelper.GetFile("DemoExpenseMeeting02.png"), Width = 160, Height = 90 }},
- },
- new Dictionary
- {
- { "sDate",DateTime.Parse("2022-09-09 08:30:00")},
- { "eDate",DateTime.Parse("2022-09-09 17:00:00")},
- { "How","Discussion requirement part2 and development"},
- { "Photo",new MiniWordPicture() { Path = PathHelper.GetFile("DemoExpenseMeeting01.png"), Width = 160, Height = 90 }},
- },
- }
-};
-MiniWord.SaveAsByTemplate(path, templatePath, value);
-```
-
-##### 模版
-
-
-
-
-##### 导出
-
-
-
-### 二级列表
-
-Tag 是 `IEnumerable` 类别. 使用方式`{{foreach` 和 `endforeach}}`.
-
-##### Example
-
-```csharp
-var value = new Dictionary()
-{
- ["TripHs"] = new List>
- {
- new Dictionary
- {
- { "sDate", DateTime.Parse("2022-09-08 08:30:00") },
- { "eDate", DateTime.Parse("2022-09-08 15:00:00") },
- { "How", "Discussion requirement part1" },
- {
- "Details", new List()
- {
- new MiniWordForeach()
- {
- Value = new Dictionary()
- {
- {"Text", "Air"},
- {"Value", "Airplane"}
- },
- Separator = " | "
- },
- new MiniWordForeach()
- {
- Value = new Dictionary()
- {
- {"Text", "Parking"},
- {"Value", "Car"}
- },
- Separator = " / "
- }
- }
- }
- }
- }
-};
-MiniWord.SaveAsByTemplate(path, templatePath, value);
-```
-
-##### Template
-
-
-
-##### Result
-
-
-
-### 条件判断
-
- `@if` 和 `@endif` tags .
-
-##### Example
-
-```csharp
-var value = new Dictionary()
-{
- ["Name"] = new List(){
- new MiniWordHyperLink(){
- Url = "https://google.com",
- Text = "測試連結22!!"
- },
- new MiniWordHyperLink(){
- Url = "https://google1.com",
- Text = "測試連結11!!"
- }
- },
- ["Company_Name"] = "MiniSofteware",
- ["CreateDate"] = new DateTime(2021, 01, 01),
- ["VIP"] = true,
- ["Points"] = 123,
- ["APP"] = "Demo APP",
-};
-MiniWord.SaveAsByTemplate(path, templatePath, value);
-```
-
-##### Template
-
-
-
-##### Result
-
-
-
-### 循环
-
- `@foreach` 和 `@endforeach` tags .
-
-##### Example
-
-```csharp
-var value = new
-{
- LoopData = new List