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