Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

306
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda