打开当前 HTML 文件并替换我需要使用 StringBuilder 的内容时,我遇到了 HTML 问题...下面是我用来执行此操作的一些代码...
'Lets replace the grid information!'
Dim sb As New StringBuilder()
sb.AppendLine(" <table>")
sb.AppendLine("<tr>")
' sb.AppendLine("<th>")
For Each column As DataGridViewColumn In DataGridView1.Columns
sb.AppendLine(" <th>" + column.HeaderText + "</th>")
Next
' sb.AppendLine("</th>")
sb.AppendLine(" </tr>")
sb.AppendLine("</table")
HTML.Replace("%TABLE%", sb.ToString)
到目前为止一切正常,我遇到的唯一问题是摆脱客户姓名字段中的“<”......我知道这是因为替换;它在那里添加了一个额外的。但是如果我把它从附加行中取出,我的网格就会变得异常......这是这个的屏幕截图......
这是我正在抓取的 HTML 文件的源代码,然后替换了我需要的内容......
<!doctype html>
<html>
<head>
<title>Invoice %Invoice%</title>
<link rel="stylesheet" href=%STYLE%>
<style type="text/css">
@import url("style.css");
</style>
</head>
<body>
<header>
<h1>Invoice %Invoice%</h1>
<address>
<p>%Business%</p>
</address>
<img src="file:///%Image%" alt="" align="right">
</header>
<article>
<h1> </h1>
<h1> </h1>
<h1> </h1>
<h1>Recipient</h1>
<address>
<p>%Company%</p>
<p>%Contact%</p>
<p>%Address%</p>
</address>
<table class="meta">
<tr>
<th><span>Invoice #</span></th>
<td><span>%Invoice%</span></td>
</tr>
<tr>
<th><span>Date</span></th>
<td><span>%Date%</span></td>
</tr>
<tr>
<th><span>Amount Paid</span></th>
<td><span id="prefix">$</span><span>0.00</span></td>
</tr>
<tr>
<th><span>Amount Due</span></th>
<td><span id="prefix">$</span><span>600.00</span></td>
</tr>
</table>
<%TABLE%> THIS IS WHERE I SEND THE TABLE TO!
</article>
<aside>
<h1> </h1>
<h1> </h1>
<h1><span>Additional Notes</span></h1>
<div contenteditable>
<p align ='center'>A finance charge of 1.5% will be made on unpaid balances after 30 days.</p>
</div>
</aside>
</body>
</html>
谢谢!