Skip to content

A 2D array to Excel file converter. Generate Microsoft Excel file from a 2D array in C#. Support making the first row headers and custom worksheet name. .Net Core 3.0 framework and depends on the Open Xml SDK.

License

Notifications You must be signed in to change notification settings

Fei-Sheng-Wu/DatasToExcel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

DatasToExcel

Target Framework Nuget Lincense

A 2D array to Excel file converter. Generate Microsoft Excel file from a 2D array in C#. Support making the first row headers and custom worksheet name. .Net Core 3.0 framework and depends on the Open Xml SDK.

Dependencies

.Net Core >= 3.0
DocumentFormat.OpenXml = 2.10.1

Main Features

  • 2D array to Excel
  • Making the first row headers

How to Use

Create a 2D array first.

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" },
};

Convert it to a Excel file and save to a local file.

datas.GenerateExcel(filename); //First row as non-headers
datas.GenerateExcel(filename, true); //First row as headers

Or save it to a MemoryStream.

//Option 1
MemoryStream ms = datas.GenerateExcel(); //First row as non-headers
MemoryStream ms = datas.GenerateExcel(true); //First row as headers

//Option 2
using (MemoryStream ms = new MemoryStream())
{
    datas.GenerateExcel(ms); //First row as non-headers
    datas.GenerateExcel(ms, true); //First row as headers
}

License

This project is under the MIT License.

About

A 2D array to Excel file converter. Generate Microsoft Excel file from a 2D array in C#. Support making the first row headers and custom worksheet name. .Net Core 3.0 framework and depends on the Open Xml SDK.

Topics

Resources

License

Stars

Watchers

Forks

Languages