<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to Display Base64 Image (Logo) in Microsoft Excel Using]]></title><description><![CDATA[<p>Hi Sir,</p>
<p>I'm working on generating an Excel file (e.g., using libraries like ExcelJS or similar) where I need to display a logo image. The image is fetched from a server and converted to a base64 string.</p>
<p>Here's the code I'm using to fetch and convert the image:</p>
<pre><code class="language-js">const axios = require('axios');

async function convertImageToBase64(imageUrl) {
    try {
        const response = await axios.get(imageUrl, { responseType: 'arraybuffer' });
        const base64Image = Buffer.from(response.data, 'binary').toString('base64');
        const contentType = response.headers['content-type'];
        return `data:${contentType};base64,${base64Image}`;
    } catch (e) {
        console.error(`Error while converting image to base64: ${e.message}`, e.stack);
        throw new Error('Error while converting image to base64: ' + e);
    }
}
</code></pre>
<p>I successfully got a base64 string like:<br />
<code>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA...</code></p>
<p>My question is: How can I display this base64 image in a generated Excel file?</p>
<p>I'm not sure how to properly embed or display the image using the base64 string.</p>
<p>Thanks in advance!</p>
]]></description><link>https://forum.jsreport.net/topic/3453/how-to-display-base64-image-logo-in-microsoft-excel-using</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 13:18:41 GMT</lastBuildDate><atom:link href="https://forum.jsreport.net/topic/3453.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 24 May 2025 14:14:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to Display Base64 Image (Logo) in Microsoft Excel Using on Mon, 26 May 2025 06:43:10 GMT]]></title><description><![CDATA[<p>Hi Sir,</p>
<p>I'm working on generating an Excel file (e.g., using libraries like ExcelJS or similar) where I need to display a logo image. The image is fetched from a server and converted to a base64 string.</p>
<p>Here's the code I'm using to fetch and convert the image:</p>
<pre><code class="language-js">const axios = require('axios');

async function convertImageToBase64(imageUrl) {
    try {
        const response = await axios.get(imageUrl, { responseType: 'arraybuffer' });
        const base64Image = Buffer.from(response.data, 'binary').toString('base64');
        const contentType = response.headers['content-type'];
        return `data:${contentType};base64,${base64Image}`;
    } catch (e) {
        console.error(`Error while converting image to base64: ${e.message}`, e.stack);
        throw new Error('Error while converting image to base64: ' + e);
    }
}
</code></pre>
<p>I successfully got a base64 string like:<br />
<code>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA...</code></p>
<p>My question is: How can I display this base64 image in a generated Excel file?</p>
<p>I'm not sure how to properly embed or display the image using the base64 string.</p>
<p>Thanks in advance!</p>
]]></description><link>https://forum.jsreport.net/post/14580</link><guid isPermaLink="true">https://forum.jsreport.net/post/14580</guid><dc:creator><![CDATA[dmex-karthik]]></dc:creator><pubDate>Mon, 26 May 2025 06:43:10 GMT</pubDate></item><item><title><![CDATA[Reply to How to Display Base64 Image (Logo) in Microsoft Excel Using on Invalid Date]]></title><description><![CDATA[<p>jsreport xlsx recipe provides <code>xlsxImage</code> helper to embed base64 image to the specific position, however, it needs further study..</p>
<p>The link to the documentation<br />
<a href="https://jsreport.net/learn/xlsx" rel="nofollow">https://jsreport.net/learn/xlsx</a></p>
<p>A demo with you case<br />
<a href="https://playground.jsreport.net/w/anon/LyTAxE8t" rel="nofollow">https://playground.jsreport.net/w/anon/LyTAxE8t</a></p>
]]></description><link>https://forum.jsreport.net/post/14581</link><guid isPermaLink="true">https://forum.jsreport.net/post/14581</guid><dc:creator><![CDATA[admin]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to How to Display Base64 Image (Logo) in Microsoft Excel Using on Mon, 26 May 2025 10:00:33 GMT]]></title><description><![CDATA[<p>Hi Sir,<br />
I have tried to follow the function</p>
<p>async function convertImageToBase64(imageUrl) {<br />
try {<br />
const response = await axios.get(imageUrl, { responseType: 'arraybuffer' });<br />
const base64Image = Buffer.from(response.data, 'binary').toString('base64');<br />
console.log('returning base64')<br />
return base64Image;<br />
} catch (e) {<br />
console.error(<code>Error while converting image to base64: ${e.message}</code>, e.stack);<br />
throw new Error('Error while converting image to base64: ' + e);<br />
}<br />
}</p>
<p>I successfully get the base64 string, and then I try to inject it into an Excel template using this syntax:</p>
<p>{{#xlsxAddImage &quot;test&quot; &quot;sheet1.xml&quot; 0 0 10 30}}<br />
{{myDataURIForImage}}<br />
{{/xlsxAddImage}}</p>
<p>However, I'm encountering the following error during template rendering:</p>
<p>Error: &quot;xlsxAddImage&quot; helper call failed<br />
(because) cannot read properties of undefined (reading '[Content_Types].xml')<br />
at module.exports (/app/node_modules/@jsreport/jsreport-core/lib/shared/createError.js:10:13)<br />
at WorkerReporter.createError (/app/node_modules/@jsreport/jsreport-core/lib/shared/reporter.js:53:12)<br />
at getEnhancedHelperError (/app/node_modules/@jsreport/jsreport-core/lib/worker/render/executeEngine.js:425:54)<br />
at /app/node_modules/@jsreport/jsreport-core/lib/worker/render/executeEngine.js:443:15<br />
wrapped by:<br />
Error: Error while executing xlsx recipe<br />
(because) &quot;xlsxAddImage&quot; helper call failed<br />
(because) cannot read properties of undefined (reading '[Content_Types].xml')<br />
(system-helpers.js line 3535:41)<br />
3533 |     const name = imageName + '.png'<br />
3534 |</p>
<blockquote>
<p>3535 |     if (!options.data.root.$xlsxTemplate['[Content_Types].xml'].Types.Default.filter(function (t) { return t.$.Extension === 'png' }).length) {<br />
|                                         ^<br />
3536 |       options.data.root.$xlsxTemplate['[Content_Types].xml'].Types.Default.push({<br />
3537 |         $: {<br />
3538 |           Extension: 'png',<br />
(system-helpers.js line 3655:17)<br />
3653 |       }<br />
3654 |<br />
3655 |       return fn.apply(this, arguments)<br />
|                 ^<br />
3656 |     }<br />
3657 |   }<br />
3658 |<br />
(system-helpers.js line 3685:30)<br />
3683 | }<br />
3684 | function xlsxAddImage (...args) {<br />
3685 |   return __xlsx.xlsxAddImage.call(this, ...args)<br />
|                              ^<br />
3686 | }<br />
3687 |<br />
3688 | function xlsxAddSheet (...args) {<br />
|                ^<br />
2952 |     },<br />
2953 |     m: function (options) {<br />
2954 |       return mergeOrFormulaCell.call(this, 'mergeCell', options)<br />
(system-helpers.js line 2983:31)<br />
2981 |       try {<br />
2982 |         if (values.length &gt; 0) {<br />
2983 |           return targetHelper.call(context, ...values, options)<br />
|                               ^<br />
2984 |         }<br />
2985 |<br />
2986 |         return targetHelper.call(context, options)<br />
(system-helpers.js line 3015:18)<br />
3013 |   __xlsxD.assertDataArg(type != null, '_D helper t arg is required')<br />
3014 |<br />
3015 |   return __xlsxD.resolveHelper(type, arguments.length, this, values, optionsToUse)<br />
|                  ^<br />
3016 | }<br />
3017 |<br />
3018 | // alias for {{_D t='r'}} helper call, we do it this way to optimize size of the generated xml<br />
(system-helpers.js line 3080:13)<br />
3078 |   }<br />
3079 |<br />
3080 |   return _D.call(this, data, options)<br />
|             ^<br />
3081 | }<br />
3082 |<br />
3083 | // alias for {{_D t='c'}} helper with autodetect call with calcChainUpdate: true</p>
</blockquote>
<p>And one more thing: Can the logo be printed directly as base64 in the Excel template? I need to print the logo multiple times and also do it dynamically.</p>
]]></description><link>https://forum.jsreport.net/post/14582</link><guid isPermaLink="true">https://forum.jsreport.net/post/14582</guid><dc:creator><![CDATA[dmex-karthik]]></dc:creator><pubDate>Mon, 26 May 2025 10:00:33 GMT</pubDate></item><item><title><![CDATA[Reply to How to Display Base64 Image (Logo) in Microsoft Excel Using on Invalid Date]]></title><description><![CDATA[<p>Please share playground demo.</p>
]]></description><link>https://forum.jsreport.net/post/14584</link><guid isPermaLink="true">https://forum.jsreport.net/post/14584</guid><dc:creator><![CDATA[admin]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to How to Display Base64 Image (Logo) in Microsoft Excel Using on Invalid Date]]></title><description><![CDATA[<p>I’m using a NestJS backend service with the jsreport package to generate reports in XLSX format. How can I dynamically insert images into the XLSX report sir.</p>
]]></description><link>https://forum.jsreport.net/post/14763</link><guid isPermaLink="true">https://forum.jsreport.net/post/14763</guid><dc:creator><![CDATA[dmex-karthik]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>