我需要任何编码员的帮助......
目前,代码读取CSV文件,然后使用Powershell将其输出到html文件。 我必须使用Powershell,因为此代码的其他位(此处未显示)使用Powershell。
如何根据单元格的值为表格上的行着色?
当前的代码位如下所示。
$datagridView1.DataSource | Export-Csv c:\tmp\test.csv
#HTML OUTPUT
$head= @"
<style>
BODY{background-color:white;}
TABLE{border-width: 3px;border-style: solid; border-color:white;border-collapse:
collapse;}
TH{border-width: 3px;padding: 2px;border-style: solid;border-color: white;background- color:yellow}
</style>
<script type="text/javascript">
var allText =[];
var allTextLines = [];
var Lines = [];
var txtFile = new XMLHttpRequest();
txtFile.open("GET", "file://c:/tmp/test.csv", true);
txtFile.onreadystatechange = function()
{
allText = txtFile.responseText;
allTextLines = allText.split(/\r\n|\n/);
};
document.write(allTextLines);<br>
document.write(allText);<br>
document.write(txtFile);<br>
</script>
"@
$datagridView1.DataSource | convertto-html -head $head –body "<H2>Query</H2>" | Out-File C:\tmp\app.html
app.html文件似乎也在创建以下四列,这些列不在CSV文件中(RowError,RowState,Table,ItemArray,HasErrors),我无法弄清楚它来自何处。
非常感谢任何帮助
答案 0 :(得分:0)
如果表数据的值为3,则以下将使任何表格背景为蓝色:
$("td:contains('3')").css({'background-color':'blue'});
jQuery是一个简化代码的神奇工具。虽然JavaScript非常适合理解基本的编程原理以及面向对象的语法。 jQuery坚持少写,做更多的座右铭。
了解更多信息visit this site。