【发布时间】:2020-01-01 03:34:57
【问题描述】:
我有一个 Excel 工作簿,我正在尝试导出为 HTML 格式(从下面的 Powershell 调用的 vba 脚本)。当我在本地机器(Win10、Office 2016)上运行它时,格式非常好。但是,当我尝试从它应该存在的服务器(WS2012、Office 2016)运行相同的脚本时,格式被破坏了(奇怪的是,在某些机器上的 Internet Explorer 中除外)。
我无法弄清楚为什么启动计算机会导致仅此部分的格式出现问题。
Excel 原文:
工作:
不工作:
所以在我的本地计算机和服务器上运行之间存在一些问题,服务器一直在 O'2013 上,但即使在尝试 O'2016 之后它仍然无法正常工作。我还禁用了宏安全性,以防万一搞砸了(它在我的本地被禁用),这也无济于事。
excel文件和vba应该没问题,因为它可以正常工作。
导出 HTML 的宏:
With ActiveWorkbook.PublishObjects.Add(xlSourceWorkbook, _
"C:\Tasks\Phonebook-HTML\Web\Index.htm", , , xlHtmlStatic, _
"TELEPHONEBOOK_18991", "")
.Publish (True)
.AutoRepublish = False
End With
工作 HTML:
<tr height="59" style="mso-height-source:userset;height:44.45pt">
<td height="59" class="xl154" style="height:44.45pt"><a href="sheet007.html#RANGE!A2"><span style="color:#0070C0;font-size:16.0pt;
font-weight:700">A</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A27"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">B</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A94"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">C</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A157"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">D</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A215"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">E</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A227"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">F</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A247"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">G</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A281"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">H</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A328"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">I</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A334"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">J</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A354"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">K</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A391"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">L</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A422"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">M</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A503"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">N</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A517"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">O</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A534"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">P</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A585"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">Q</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A587"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">R</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A634"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">S</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A695"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">T</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A718"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">U</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A719"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">V</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A741"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">W</span></a></td>
<td class="xl154"><a href=""><span style="color:#0070C0;font-size:16.0pt;
font-weight:700">X</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A767"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">Y</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A771"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">Z</span></a></td>
</tr>
不工作的 HTML:
<tr height="59" style="mso-height-source:userset;height:44.45pt">
<td height="59" class="xl154" style="height:44.45pt"><a href="sheet007.html#RANGE!A2"><span style="color:#0070C0;font-size:16.0pt;
font-weight:700">A</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A27"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">B</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A94"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">C</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A157"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">D</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A215"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">E</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A227"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">F</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A247"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">G</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A281"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">H</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A328"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">I</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A334"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">J</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A354"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">K</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A391"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">L</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A422"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">M</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A503"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">N</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A517"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">O</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A534"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">P</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A585"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">Q</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A587"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">R</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A634"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">S</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A695"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">T</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A718"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">U</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A719"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">V</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A741"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">W</span></a></td>
<td class="xl154"><a href=""><span style="color:#0070C0;font-size:16.0pt;
font-weight:700">X</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A767"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">Y</span></a></td>
<td class="xl154"><a href="sheet007.html#RANGE!A771"><span style="color:#0070C0;
font-size:16.0pt;font-weight:700">Z</span></a></td>
</tr>
【问题讨论】:
标签: html excel vba powershell