AKS*_*AKS 5 javascript excel image insert
我的html页面包含一个嵌入图像(png),我想将其动态插入到excel文件中。我在下面尝试用我喜欢的名称和工作表名称创建了excel文件,尽管工作表的名称与文件名相同,但不确定如何使用以下代码进行设置
//creating a temporary HTML link element (they support setting file names)
var a = document.createElement('a');
var postfix = 'AKS'
//getting data from our div that contains the HTML table
var data_type = 'data:application/vnd.ms-excel';
var table_div = document.getElementById('myDynamicImage');
var table_html = table_div.outerHTML.replace(/ /g, '%20');
a.href = data_type + ', ' + table_html;
//setting the file name
a.download = 'exported_table_' + postfix + '.xls';
//triggering the function
a.click();
Run Code Online (Sandbox Code Playgroud)
但是dataURI格式的图像内容在excel中作为文本而不是图像插入。我可以为图像设置它吗?我可以控制位置等吗?我可以控制工作表名称吗?我用其他但有点复杂的方法tableToExcel做到了这一点。
归档时间: |
|
查看次数: |
3575 次 |
最近记录: |