Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

305
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!