Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

785
Vistas
How to generate PDF from Excel MemoryStream created using EPPlus.core?

I have to create a API in dot net core which will return the excel as PDF. Excel works fine but when I try to send it in PDF content as you can see in the following code:

        [HttpPost]
        [Route("ExportToPdf")]
        public IActionResult ExportToPdf()
        {
            MemoryStream stream = MyClassExcelWorkBook.GetExcel();
            return File(stream, "application/pdf", "excel-Demo.pdf");
        }

MyClassExcelWorkBook is a class where in GetExcel() will return MemoryStream of excel that has been created. I have created the excel memory stream from epplus.core library that I have installed from NuGet. Can anyone help in creating the excel memory stream to pdf as response?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

An xlsx stream is a Microsoft zip archive but a PDF is a printer output so a basic application cannot convert a zip file into a printer file unless for example using the MS interop export XLS render to MS PDF printer. And that would be the best method on an Office.net PC.

Presumably you are allowing for MS.net users without any version of an installed MS Office.

There are many variations or addons to EPPlus that can do the necessary conversion to PDF and https://www.nuget.org/packages/EpplusExcel/ is specifically designed as one of them but as its V1 and not updated the past 7 years may not be best final supported solution, but worth a try just to see how its methodologies work for you.

The most common converter avoiding interop is using Libre/Open Office with its basic language alternative to VBA to print spread sheet areas to PDF printouts.

I would avoid any X/HTML methods as changing from sheet area structure to reflowing text which is not suited to PDF fixed page production, unless each page/sheet is converted to a fixed layout equal to a single PDF page.

over 4 years ago · Santiago Trujillo Denunciar

0

According to the official documentation of the EPPlus, the library is not supporting any direct export to PDF.

But there is a workaround option would be exporting the Excel using the one of the EPPlus 6.0 beta feature, HtmlExporter and get the HTML and styles.

This can be fed into the html to pdf converter like iText pdfHTML, sharkPdf(.NET wrapper for wkhtmltopdf) to export as PDF.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda