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

303
Vistas
How to resize images when exporting html table as excel?

I have a basic HTML table which is structured like this:

<style>
    .demo {
        border:1px solid #C0C0C0;
        border-collapse:collapse;
        padding:5px;
    }
    .demo th {
        border:1px solid #C0C0C0;
        padding:5px;
        background:#F0F0F0;
    }
    .demo td {
        border:1px solid #C0C0C0;
        padding:5px;
    }
</style>
<table class="demo">
    <caption>Table 1</caption>
    <thead>
    <tr>
        <th>Header 1</th>
        <th>Header 2</th>
        <th>Header 3</th>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td>hello</td>
        <td>&nbsp;World</td>
        <td><img width="150px" src="https://www.hdnicewallpapers.com/Walls/Big/Rainbow/Rainbow_on_Mountain_HD_Image.jpg" /></td>
    </tr>
    <tr>
        <td>&nbsp;1</td>
        <td>&nbsp;1</td>
        <td><img width="150px" src="https://www.hdnicewallpapers.com/Walls/Big/Rainbow/Rainbow_on_Mountain_HD_Image.jpg" /></td>
    </tr>
    <tr>
        <td>&nbsp;2</td>
        <td>&nbsp;2</td>
        <td><img width="150px" src="https://www.hdnicewallpapers.com/Walls/Big/Rainbow/Rainbow_on_Mountain_HD_Image.jpg" /></td>
    </tr>
    </tbody>
</table>

If you copy this code and paste it into an HTML document, you will find the results as a 3x3 table + header. First 2 columns have text, third one has an image 150px wide. It works perfectly when I export as PDF, but when I export as excel using the following method:

<a href={'data:application/vnd.ms-excel,' + encodeURIComponent(document.getElementsByClassName("print-table-legacy")[0]?.outerHTML)} download={"Projects Report - " + getDateFromRange(filterOptions._date_range) + ".xls"} onClick={e => {}}>Export (With Pictures)</a>

the images appear to be extremely large (original size - if it is 1920x1080 it remains that size ignoring my 150px css rule).

This is not a viable solution for my problem of including images inside of excel. What is the point of having the images if you have to go through each image and resize it? You are better off without them at that point.

Is there a way to resize the actual image before I export it to excel? These images are stored on a remote server and resizing them over there is not an option either as the originals are needed and storage space is kind of tight.

about 4 years ago · Juan Pablo Isaza
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