TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jayesh Vyas
NA
187
20k
Export Base64 Image to Excel.
Dec 20 2017 5:00 AM
Hii all,
I am trying to export base 64 age image to excel, but it is giving me a cross signed image instead of the original image.
you can see my code below.
<
html
>
<
head
>
</
head
>
<
body
>
<
table
id
=
"table"
border
=
"1"
class
=
"pvtTable"
data-numrows
=
"6"
data-numcols
=
"10"
>
<
tbody
>
<
tr
>
<
th
colspan
=
"1"
rowspan
=
"1"
>
</
th
>
<
th
class
=
"pvtAxisLabel"
>
Product Name
</
th
>
<
th
class
=
"pvtColLabel"
colspan
=
"1"
rowspan
=
"2"
>
610164
</
th
>
<
th
class
=
"pvtColLabel"
colspan
=
"1"
rowspan
=
"2"
>
110152909
</
th
>
<
th
class
=
"pvtColLabel"
colspan
=
"1"
rowspan
=
"2"
>
B1
</
th
>
<
th
class
=
"pvtColLabel"
colspan
=
"1"
rowspan
=
"2"
>
Derived
</
th
>
<
th
class
=
"pvtTotalLabel"
rowspan
=
"2"
>
Count
</
th
>
</
tr
>
<
tr
>
<
th
class
=
"pvtAxisLabel"
>
Thumbnail12Prod
</
th
>
<
th
>
</
th
>
</
tr
>
<
tr
>
<
th
class
=
"pvtRowLabel"
rowspan
=
"1"
colspan
=
"2"
>
<
a
href
=
"#"
>
<
img
src
=
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAACk5JREFUeNrUmQlsW/Udx7/P933EdkqcO016xKXt2AohrNBWdKNQWi6BxKVtQKVs0ujEhiYBHamEJlhBZdU0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g3T4U0m0/61a9eira0Nn8YLER+P4Z41IotTJv23c55+k84xfE0OQw7eodPp9vt8Pm1XmG2wDg4O4kCnfffOarGRbonQOYSv4aH9yMe2FsmIervdvodtZ7N9SVVVd/9zV/TFr7LNuCQS0posnocgCHvIqFnBf61WYFosOAg+cTkbvYtuwDf50OEbfvxXgAEAFpyqPqutRYcAAAAASUVORK5CYII="
>
</
a
>
</
th
>
<
td
class
=
"pvtVal row0 col4"
data-value
=
"1"
>
1
</
td
>
<
td
class
=
"pvtVal row0 col7"
data-value
=
" "
>
</
td
>
<
td
class
=
"pvtVal row0 col8"
data-value
=
" "
>
</
td
>
<
td
class
=
"pvtVal row0 col9"
data-value
=
" "
>
</
td
>
<
td
class
=
"pvtTotal rowTotal"
data-value
=
"1"
data-for
=
"row0"
>
1
</
td
>
</
tr
>
<
tr
>
<
th
class
=
"pvtRowLabel"
rowspan
=
"1"
colspan
=
"2"
>
<
a
href
=
"#"
>
<
img
id
=
"imgElem"
src
=
"data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAp1JREFUeNqEU21IU1EYfu7unW5Ty6aBszYs6MeUjGVYokHYyH5E1B9rZWFEFPQnAwmy6Hc/oqhfJsRKSSZGH1JIIX3MNCsqLTD9o1Oj6ebnnDfvvefezrnbdCHhCw/n433P8z7nPe/hBEEAtX0U7hc164uwuvVSXKwZLoOmaRDim+7m9vZa0WiEKSUFFpNpCWlmMyypqTDRuYn6t3k8vmQ2gRDCxs0t9fW45F52aBTROJLtZl7nEZad2m+KtoQCQ0FBARyOCGRZ/q92I1WgqqXlfdd95VsrK8/pChIEqqpCkiQsiCII0aBQZZoWl8lzFDwsFjMl0DBLY8Lj41hBwK4jSQrWOIphL6xYyhwJDWGo6wFSaH1Y3PTCAsITE1oyAa8flhWkbSiCLX8vun11eiGIpiJ/z2nYdx5HqLdVV7elrOzsuqysL3rmBIGiKPizKCHHWY4PLVeQbnXAdegqdhy+hu8dDTBnbqQJZJ1A7u+vz7RaiymWCZgCRSF6Edk8b9cx+B/W6WuVxPaZnyiqXoPpyUmVYvkKTIFClHigEieKjYuSvETUllaF4GAUM1NT6ooaJDKx+aDfC9fByxj90REb+9ppmIoAscH/6leg8MS9DJXPAM9xHCM443K57C6biMjcHDaVVCHw9RmCA2/RGC5C00AqXk/m4p20HZK4CM/J3Zk9n0ecMBhDQnJHcrTisyMfdQXOilrdMfxcwoHq/fg5R59TiQV3hYGKo6X2J/c7LyQIjOx9GXhOw/zoJ8wEevRGyp53o/lGMNYsBgPtEwLecwov7/jGDKa1twT6o3KpL4MdZgGsWZLtfPr7f1q58k1JNHy7YYaM+J+K3Y2PmAIbRavX66229hrGVvvL5uzsHDEUvUu+NT1my78CDAAMK1a8/QaZCgAAAABJRU5ErkJggg=="
alt
=
"Red dot"
/>
</
a
>
</
th
>
<
td
class
=
"pvtVal row1 col4"
data-value
=
" "
>
</
td
>
<
td
class
=
"pvtVal row1 col5"
data-value
=
"1"
>
1
</
td
>
<
td
class
=
"pvtVal row1 col8"
data-value
=
" "
>
</
td
>
<
td
class
=
"pvtVal row1 col9"
data-value
=
"2"
>
2
</
td
>
<
td
class
=
"pvtTotal rowTotal"
data-value
=
"3"
data-for
=
"row1"
>
3
</
td
>
</
tr
>
</
tbody
>
</
table
>
<
input
type
=
"button"
id
=
"export-data"
src
=
"images/icon/icon-excel.png"
value
=
"Export to Excel"
onclick
=
"tableToExcel('table')"
/>
<
script
src
=
"https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"
>
</
script
>
<
script
>
var
tableToExcel
= (function () {
var
uri
=
'data:application/vnd.ms-excel;base64,'
,
template
=
'<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
,
base64
=
function
(s) { return window.btoa(unescape(encodeURIComponent(s))) }
,
format
=
function
(s, c) { return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; }) }
return function (table, name) {
if (!table.nodeType)
table
=
document
.getElementById(table)
var
ctx
= { worksheet: name || 'Worksheet', table: table.innerHTML }
window.location.href
=
uri
+ base64(format(template, ctx))
}
})()
</
script
>
</
body
>
</
html
>
Reply
Answers (
3
)
Change icon in Google map ?
get element from the array