[英]How can I convert each cell in HTML table column to a downloadable link, that references a local zip file?
I am currently designing a web application that would read an XLSX file and convert it into an HTML table. 我目前正在设计一个Web应用程序,它将读取XLSX文件并将其转换为HTML表格。 The XLSX file contains columns that is concatenated into the "Info" column
XLSX文件包含连接到“信息”列的列
I have three columns, "FileName", "Info", "Download", that becomes populated with a for loop. 我有三列,“FileName”,“Info”,“Download”,它们将填充for循环。 In this for loop, I would like to add a link in each cell under the "Download" column, that references a zip file in my local directory.
在这个for循环中,我想在“下载”列下的每个单元格中添加一个链接,该链接引用我本地目录中的zip文件。
I have already tried createElement('a') within my loop 我已经在循环中尝试了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);
or 要么
cell.innerHTML += '<a href="' + excelRows[i].FileName + '.zip">Some Link</a>';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.