-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3500b9d
commit b6fa45b
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# DatasToExcel | ||
|
||
[![Target Framework](https://img.shields.io/badge/%2ENet%20Core-3.0-green.svg)](https://docs.microsoft.com/en-us/dotnet/core/about) | ||
[![Lincense](https://img.shields.io/badge/Lincense-MIT-orange.svg)](https://github.com/Fei-Sheng-Wu/DatasToExcel/blob/1.0.0/LICENSE.txt) | ||
|
||
> A 2D array to Excel file converter, support header first row and fixed headers. It uses .Net Core 3.0 as framework and only depends on the Open Xml SDK. | ||
## Dependencies | ||
|
||
**.Net Core** >= 3.0 | ||
**DocumentFormat.OpenXml** = 2.10.1 | ||
|
||
## Main Features | ||
|
||
- [x] 2D array to Excel | ||
- [x] Header first row (optional) | ||
- [x] Fixed first row (optional) | ||
|
||
## How to Use | ||
|
||
Create a 2D array first. | ||
|
||
```c# | ||
string[,] datas = new string[,] | ||
{ | ||
{ "Name", "Country", "Age", "Career" }, | ||
{ "Helen", "U.S.", "21", "Police" }, | ||
{ "Jucia", "Canada", "34", "Dancer" }, | ||
{ "Erik", "Canada", "13", "Student" }, | ||
{ "Bob", "British", "26", "Business person" }, | ||
{ "Nancy", "Russia", "64", "Fisherman" }, | ||
}; | ||
``` | ||
|
||
And convert it to Excel and save to a fixed path. | ||
|
||
```c# | ||
datas.GenerateExcel(filename); //Do not header first row | ||
datas.GenerateExcel(filename, true); //Header first row | ||
``` | ||
|
||
Or save it to a memory stream. | ||
|
||
```c# | ||
//Option 1 | ||
MemoryStream ms = datas.GenerateExcel(); //Do not header first row | ||
MemoryStream ms = datas.GenerateExcel(true); //Header first row | ||
//Option 2 | ||
using (MemoryStream ms = new MemoryStream()) | ||
{ | ||
datas.GenerateExcel(ms); //Do not header first row | ||
datas.GenerateExcel(ms, true); //Header first row | ||
} | ||
``` | ||
|
||
## License | ||
|
||
This project is under the [MIT License](https://github.com/Fei-Sheng-Wu/DatasToExcel/blob/1.0.0/LICENSE.txt). |