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> World</td>
<td><img width="150px" src="https://www.hdnicewallpapers.com/Walls/Big/Rainbow/Rainbow_on_Mountain_HD_Image.jpg" /></td>
</tr>
<tr>
<td> 1</td>
<td> 1</td>
<td><img width="150px" src="https://www.hdnicewallpapers.com/Walls/Big/Rainbow/Rainbow_on_Mountain_HD_Image.jpg" /></td>
</tr>
<tr>
<td> 2</td>
<td> 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.