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:
Converttakes the.xlsxas abyte[]and returns the PDF as abyte[]. - No
PageSetupparameter: 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
PdfFontOptionsto supply the font.