我如何将Excel中的数据插入到HTML表格中?

我有一个包含足球统计数据的Excel文件,我希望能够改变Excel的数字,并在这样做的网站自动更新其表。

有没有可能的方法来做到这一点?

这并不能完全回答你的问题,但我想把它作为一个部分的答案。 我有一个通用的过程(方法),我不时使用将Excel Table (又名ListObject )转换成HTML表。 Perl有一个出色的模块,但是我从来没有发现任何类似于VBA的东西,所以我的手写代码。

唯一需要注意的是你的数据必须在表格中。 如果它来自RDBMS,那么最简单的方法就是通过MS Query将其引入,MS Query会自动将输出呈现为Table / ListObject。

我知道你正在谈论Web,并没有提到VBA – 只要拿这个是值得的。 我希望它有一些有用的组件,你可以收集。

 Function TableToHtml(ByRef Table As ListObject, Title As String) As String Dim row As ListRow Dim header, col As range Dim output As String output = _ "<html>" & vbCrLf & _ " <head>" & vbCrLf & _ " <title>" & vbCrLf & _ Title & vbCrLf & _ " </title>" & vbCrLf & _ " </head>" & vbCrLf & _ "<body>" & vbCrLf & _ "<font size=""5"">" & Title & "</font><br><br>" & vbCrLf & _ "<table border='1px' cellpadding='5' cellspacing='0' style='border: solid 1px Black; font-size: small;'>" output = output & "<tr align='center' valign='top'>" & vbCrLf Set header = Table.HeaderRowRange For Each col In header.Columns output = output & " <td align='center' valign='top'>" & col.Value & "</td>" & vbCrLf Next col output = output & "</tr>" & vbCrLf For Each row In Table.ListRows output = output & "<tr align='left' valign='top'>" & vbCrLf For Each col In row.range.Columns output = output & " <td align='center' valign='top'>" & col.Value & "</td>" & vbCrLf Next col output = output & "</tr>" & vbCrLf Next row Dim o As Object output = output & "<tr align='left' valign='top'>" & vbCrLf For Each header In Table.TotalsRowRange output = output & " <td align='center' valign='top'>" & header.Value & "</td>" & vbCrLf Next header output = output & "</tr>" & vbCrLf output = output & "</table>" & vbCrLf & "</body>" & vbCrLf & "</html>" TableToHtml = output End Function 

是的,这是非常蛮力的。