Shalaby.Convertors.FileConvertorHelpers 1.0.0

dotnet add package Shalaby.Convertors.FileConvertorHelpers --version 1.0.0
                    
NuGet\Install-Package Shalaby.Convertors.FileConvertorHelpers -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Shalaby.Convertors.FileConvertorHelpers" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Shalaby.Convertors.FileConvertorHelpers" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Shalaby.Convertors.FileConvertorHelpers" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Shalaby.Convertors.FileConvertorHelpers --version 1.0.0
                    
#r "nuget: Shalaby.Convertors.FileConvertorHelpers, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Shalaby.Convertors.FileConvertorHelpers&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Shalaby.Convertors.FileConvertorHelpers&version=1.0.0
                    
Install as a Cake Tool

FilesHelpers

FilesHelpers is a lightweight utility library for .NET developers that simplifies exporting data to Excel (.xlsx) and PDF (.pdf) formats. Built using ClosedXML and iTextSharp, it provides elegant exports for both collections and single objects, with out-of-the-box support for Arabic and RTL (Right-to-Left) layouts.


Features

  • Export lists (IEnumerable<T>) to Excel or PDF with custom headers
  • Export single objects as key-value tables
  • Auto-format property names (e.g. FirstNameFIRST NAME)
  • PDF supports embedded fonts and RTL (Arabic, Hebrew, etc.)
  • Designed for use in ASP.NET Core MVC, Razor Pages, and API responses
  • Returns output as MemoryStream-based DTOs for direct downloads

Installation

Install via NuGet:

dotnet add package FilesHelpers

Or via Package Manager Console:

Install-Package FilesHelpers

Usage Examples

Export a List to Excel

var users = new List<User>
{
    new User { Id = 1, Name = "Amr", Email = "amr@example.com" },
    new User { Id = 2, Name = "Sara", Email = "sara@example.com" }
};

var columns = new List<(string headerName, string objectPropName)>
{
    ("User ID", "Id"),
    ("Full Name", "Name"),
    ("Email", "Email")
};

var result = FilesHelpers.ExportExcelFile(users, columns, "Users List");

Export a List to PDF (with Arabic font support)

var result = FilesHelpers.ExportPdfFile(env, users, columns, "Users Report");

Ensure you have a font like Cairo-Regular.ttf in wwwroot/fonts for Arabic support.

Export a Single Object to PDF (Key-Value Table)

var user = new {
    UserName = "Admin",
    Email = "admin@example.com",
    CreatedAt = DateTime.UtcNow
};

var result = FilesHelpers.ExportObjectToPdf(env, user, "User Details");

Export a Single Object to Excel

var result = FilesHelpers.ExportObjectToExcel(user, "User Info");

DTO Output Format

Both methods return a FileDto:

public record FileDto
{
    public MemoryStream FileContent { get; set; }
    public string FileName { get; set; }
    public string ContentType { get; set; }
}

Use this in a controller to return the file to the browser.

return File(fileDto.FileContent, fileDto.ContentType, fileDto.FileName);

Dependencies


License

This project is licensed under the MIT License.


Author

Amr Shalaby Feel free to contribute, open issues, or suggest improvements.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 124 6/25/2025