繁体   English   中英

如何将HTML表格列中的每个单元格转换为引用本地zip文件的可下载链接?

[英]How can I convert each cell in HTML table column to a downloadable link, that references a local zip file?

我目前正在设计一个Web应用程序,它将读取XLSX文件并将其转换为HTML表格。 XLSX文件包含连接到“信息”列的列

我有三列,“FileName”,“Info”,“Download”,它们将填充for循环。 在这个for循环中,我想在“下载”列下的每个单元格中添加一个链接,该链接引用我本地目录中的zip文件。

我已经在循环中尝试了createElement('a')

for (var i = 0; i < excelRows.length; i++) {
    //Add the data row.
    var row = table.insertRow(-1);

    //Add the data cells.
    var cell = row.insertCell(-1);

    if(headerCell.getElementById = 'FileName'){
    cell.innerHTML = excelRows[i].FileName;
    //cell.setAttribute("id", "FileName");

    }
    cell = row.insertCell(-1);
    cell.innerHTML = excelRows[i].Title + " ; " + excelRows[i].Summary + " ; " + excelRows[i].Author;

    if(headerCell.getElementById = 'Download'){
    cell = row.insertCell(-1);



    cell.innerHTML = document.createElement('a');
      //cell.innerHTML = excelRows[i].FileName + ".zip";

    }
var a = document.createElement('a');

a.href = excelRows[i].FileName + ".zip";
a.innerText = 'Some Link';

cell.appendChild(a);

要么

cell.innerHTML += '<a href="' + excelRows[i].FileName + '.zip">Some Link</a>';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM