[英]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.