javascript - Powershell Import-Csv 试图将 CSV 文件转换为 HTML,但我不知道如何将 ID 参数添加到表中(需要 jscript)
问题描述
$bodyformat +=
'<input type="text" id="search_field_input" onkeyup="search_table()" placeholder="Type to search">'
$bodyformat +=
'<script>
function search_table(){
var input, filter, table, tr, td, i;
input = document.getElementById("search_field_input");
filter = input.value.toUpperCase();
table = document.getElementById("table_id");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td") ;
for(j=0 ; j<td.length ; j++)
{
let tdata = td[j] ;
if (tdata) {
if (tdata.innerHTML.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
break ;
} else {
tr[i].style.display = "none";
}
}
}
}
}
</script>'
$html = Import-Csv -delimiter ',' -Path D:\Temp\final.csv | Foreach {$ .link= '{1}' -f $ .Link,$ .Title;$ } | 选择ID,链接 | ConvertTo-Html -Head $htmlformat -Body $bodyformat
$html -replace "<","<" -replace """,'"' -replace ">",">" | 出站文件 D:\Outbound\index.html
解决方案
推荐阅读
- python - 如何在 python 脚本中发送带有变量的詹金斯电子邮件?
- docker - 如何基于其他 env_variable 在 docker-compose 中设置 env 变量
- javascript - 为什么当我关闭弹出窗口时 videojs 被禁用?
- jenkins - fileExists 是否适用于 Jenkins 从属服务器或仅适用于主服务器?
- vagrant - 找不到“host_compress_magento_code”供应商
- c# - 在第 N 次出现 char 时拆分字符串
- python - 匹配在下一次出现第一个之前没有跟随另一个特定行的特定行
- authentication - 如何使用 keycloak 强制每个客户端登录(¿最佳实践?)
- angular - 带有 HTTPS 安全连接的离子服务
- assembly - 如何将参数传递给ARM汇编语言?