From 4bb1517c247272e7fad56bd202121d56dd27a5fd Mon Sep 17 00:00:00 2001 From: wei Date: Tue, 14 Sep 2021 15:16:56 +0800 Subject: [PATCH] [Doc] DataReader export multiple sheets #283 --- README.md | 17 +++++++++++++++-- README.zh-CN.md | 21 ++++++++++++++++----- README.zh-Hant.md | 19 ++++++++++++++++--- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index efe5ddf..dc216a8 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ Logic : create a total of 10,000,000 "HelloWorld" excel | OpenXmlSdk | 'OpenXmlSdk Create Xlsx' | 2,621 MB | 42.47399 sec | | ClosedXml | 'ClosedXml Create Xlsx' | 7,141 MB | 140.93992 sec | -### Excel Query +### Excel Query/Import #### 1. Execute a query and map the results to a strongly typed IEnumerable [[Try it]](https://dotnetfiddle.net/w5WD1J) @@ -291,7 +291,7 @@ support variable length and width multi-row and column filling -### Create Excel +### Create/Export Excel 1. Must be a non-abstract type with a public parameterless constructor . @@ -339,6 +339,19 @@ MiniExcel.SaveAs(path, reader); ![image](https://user-images.githubusercontent.com/12729184/121275378-149a5e80-c8bc-11eb-85fe-5453552134f0.png) +DataReader export multiple sheets (recommand by Dapper ExecuteReader) + +```csharp +using (var cnn = Connection) +{ + cnn.Open(); + var sheets = new Dictionary(); + sheets.Add("sheet1", cnn.ExecuteReader("select 1 id")); + sheets.Add("sheet2", cnn.ExecuteReader("select 2 id")); + MiniExcel.SaveAs("Demo.xlsx", sheets); +} +``` + #### 4. Datatable diff --git a/README.zh-CN.md b/README.zh-CN.md index 07503cf..4167efe 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -108,8 +108,7 @@ Benchmark History : [Link](https://github.com/shps951023/MiniExcel/issues/276) - -### 读 Excel +### 读/导入 Excel @@ -291,8 +290,7 @@ MiniExcel.Query(path,useHeaderRow:true,startCell:"B3") - -### 写 Excel +### 写/导出 Excel 1. 必须是非abstract 类别有公开无参数构造函数 2. MiniExcel SaveAs 支援 `IEnumerable参数延迟查询`,除非必要请不要使用 ToList 等方法读取全部数据到内存 @@ -331,7 +329,7 @@ output : -#### 3. IDataReader 参数 +#### 3. IDataReader - 推荐使用,可以避免载入全部数据到内存 @@ -341,6 +339,19 @@ MiniExcel.SaveAs(path, reader); ![image](https://user-images.githubusercontent.com/12729184/121275378-149a5e80-c8bc-11eb-85fe-5453552134f0.png) +推荐 DataReader 多表格导出方式(建议使用 Dapper ExecuteReader ) + +```csharp +using (var cnn = Connection) +{ + cnn.Open(); + var sheets = new Dictionary(); + sheets.Add("sheet1", cnn.ExecuteReader("select 1 id")); + sheets.Add("sheet2", cnn.ExecuteReader("select 2 id")); + MiniExcel.SaveAs("Demo.xlsx", sheets); +} +``` + #### 4. Datatable diff --git a/README.zh-Hant.md b/README.zh-Hant.md index 591fbe4..0916337 100644 --- a/README.zh-Hant.md +++ b/README.zh-Hant.md @@ -108,7 +108,7 @@ Benchmark History : [Link](https://github.com/shps951023/MiniExcel/issues/276) -### 讀 Excel +### 讀/導入 Excel - 支持任何 stream 类型 : FileStream,MemoryStream @@ -293,7 +293,7 @@ MiniExcel.Query(path,useHeaderRow:true,startCell:"B3") -### 寫 Excel +### 寫/導出 Excel 1. 必須是非abstract 類別有公開無參數構造函數 2. MiniExcel SaveAs 支援 `IEnumerable參數延遲查詢`,除非必要請不要使用 ToList 等方法讀取全部資料到記憶體 @@ -336,7 +336,7 @@ output : -#### 3. IDataReader 參數 +#### 3. IDataReader - 推薦使用,可以避免載入全部數據到記憶體 @@ -346,6 +346,19 @@ MiniExcel.SaveAs(path, reader); ![image](https://user-images.githubusercontent.com/12729184/121275378-149a5e80-c8bc-11eb-85fe-5453552134f0.png) +推薦 DataReader 多表格導出方式(建議使用 Dapper ExecuteReader ) + +```csharp +using (var cnn = Connection) +{ + cnn.Open(); + var sheets = new Dictionary(); + sheets.Add("sheet1", cnn.ExecuteReader("select 1 id")); + sheets.Add("sheet2", cnn.ExecuteReader("select 2 id")); + MiniExcel.SaveAs("Demo.xlsx", sheets); +} +``` + #### 4. Datatable