Convert XLSX to PDF in C#

XlsxToPdfConverter renders an Excel workbook to PDF, with no Excel and no LibreOffice. Each worksheet's own print setup decides its pages.

using DocToolkit;

byte[] xlsx = File.ReadAllBytes("input.xlsx");
byte[] pdf = XlsxToPdfConverter.Convert(xlsx);
File.WriteAllBytes("output.pdf", pdf);

What it needs

  • No browser, headless or otherwise.
  • No Office install, and no LibreOffice.
  • No native files: managed code only.
  • No network at runtime, unless you ask for it.

Good to know

  • Synchronous: Convert takes the .xlsx as a byte[] and returns the PDF as a byte[].
  • No PageSetup parameter: the workbook's per-sheet print setup is honoured.
  • Merged cells render; a sheet's right-to-left direction does not.
  • A cell holding characters the reachable fonts do not cover is refused, naming the character. Pass PdfFontOptions to supply the font.

Install

dotnet add package Ank.DocToolkit

NuGetDocumentationGitHub