ExcelToPdf 6.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ExcelToPdf --version 6.0.0
NuGet\Install-Package ExcelToPdf -Version 6.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="ExcelToPdf" Version="6.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ExcelToPdf --version 6.0.0
#r "nuget: ExcelToPdf, 6.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.
// Install ExcelToPdf as a Cake Addin
#addin nuget:?package=ExcelToPdf&version=6.0.0

// Install ExcelToPdf as a Cake Tool
#tool nuget:?package=ExcelToPdf&version=6.0.0

ExcelToPdf

中文版 | English

This is a simple project to export Excel to PDF.

It consists of two steps:

  1. Use NpoiExcelHelper. ExcelToHtml method will excel export to HTML
  2. Use Pdfhelper.HtmlToPdf to convert HTML to PDF

Npoi and WkHtmlToPdf did almost all the work, and because of that, please go to these two projects to view the relevant documents, thank them very much

This project also provides a simple encapsulation of customizations, see the customization section of the documentation.

Sample

For details, please refer to ExcelToPdfSample project.

public void OnPostSample2()
{
	var excelFileInfo = new FileInfo("TestData/sample.xls");
	var htmlFileInfo = new FileInfo("Output/sample.html");
	var pdfFileInfo = new FileInfo("Output/sample.pdf");

	if (htmlFileInfo.Directory != null && !htmlFileInfo.Directory.Exists)
	{
		htmlFileInfo.Directory.Create();
	}

	// export excel to html
	NpoiExcelHelper.ExcelToHtml(excelFileInfo.FullName, htmlFileInfo.FullName, configOptions: option =>
	{
		option.OutputColumnHeaders = true;
	});

	// convert html to pdf
	_converter.HtmlToPdf(htmlFileInfo.FullName, pdfFileInfo.FullName,
		config =>
		{
			config.Orientation = Orientation.Landscape;
		});
}

Note that using asp.net requires the injection of IConverter first, as follows:

in StartUp.cs

// injection
services.AddHtmlToPdf();

Custom

Custom excel export

With the NpoiExcelHelper.ExcelToHtml method, can use the configOptions parameters to HTML do custom processing for export, specific definition refer to:Npoi ExcelToHtmlConverter

Custom pdf convert

With the PdfHelper.htmltopdf method, you can use the configGlobalSettings parameter to define the PDF export. For details, see: WkHtmlToPdf-DotNet

Docker and linux

How-to-use-NPOI-on-Linux

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
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
6.0.4 874 8/16/2023
6.0.3 136 8/8/2023
6.0.2 143 7/27/2023
6.0.1 3,058 1/26/2022
6.0.0 621 1/24/2022