Free C# library to save as Excel file

patrick

Well-known member
Joined
Dec 5, 2021
Messages
251
Programming Experience
1-3
Hello.

In ASP.NET C# ,
There is free library to save as excel file?
The Data type to saved as excel file is Datatable(DataRow).

ASP.NET = C# Free library

using Microsoft.Office.Interop.Excel is Excluded.
 
Last edited:
Does it really have to be an Excel file? I hope you know that Excel can open up .CSV files.
 
I hope you know that Excel can open up .CSV files.

Yeah but everything around CSV is just.. Nasty.

At least Excel files can have data typing applied to the values so it's not guesswork on the behalf of the reader..
 
Look at SpreadSheetLight which is a free to use library for .xlsx Excel

Method to save DataTable to Excel:
public static void ExportToExcel(DataTable table, string fileName, bool includeHeader, string sheetName)
{
    using var document = new SLDocument();

    // import to first row, first column
    document.ImportDataTable(1, SLConvert.ToColumnIndex("A"), table, includeHeader);

    // give sheet a useful name
    document.RenameWorksheet(SLDocument.DefaultFirstSheetName, sheetName);

    document.SaveAs(fileName);
}
 
@kareninstructor OP says they cannot (incapable? prohibited?) download from Nuget

I wonder about this and what stopping them from downloading but alas even know that I still find value in posting it.

Perhaps if this is because of a company policy they might ask for an exception to the rule.
 
Some companies are under the belief that just downloading binaries instead of building from source will lead to code that cannot be maintained in the future should the need arise. They don't understand that downloading binaries are okay, as long as the developers also take a snapshot of the source code that should match the binaries.

It was reading the FAQ. On the positive side, when you download the Nuget package, you also get the source as part of the package (instead of going to GitHub or contacting the author). On the negative side, you quite literally get the source code, and only the source code. (The author claims that this complies with the definition of "open source", but as I understand things, the way thr OSF defines "open source" is that the necessary build scripts/files should also be supplied. He makes a snarky remark that if you are incapable of being able to make a build project with just the source code, then you probably are not yet skilled enough to be touching the code.)

So if need be the OP can get the NuGet package by simulating all the HTTP requests that NuGet does under the covers, and they can technically not have used NuGet to get the library.
 
Hello.

In ASP.NET C# ,
There is free library to save as excel file?
The Data type to saved as excel file is Datatable(DataRow).

ASP.NET = C# Free library

using Microsoft.Office.Interop.Excel is Excluded.

Probably too late, but have you tried CloseXML --> GitHub - ClosedXML/ClosedXML: ClosedXML is a .NET library for reading, manipulating and writing Excel 2007+ (.xlsx, .xlsm) files. It aims to provide an intuitive and user-friendly interface to dealing with the underlying OpenXML API.
You can create and save as Excel file format.

Happy coding
 

Latest posts

Back
Top Bottom