彰化一整天的論壇

 找回密碼
 立即註冊
搜索
查看: 34|回復: 0

將excel表格轉換成html語法

[複製鏈接]
發表於 2018-1-29 14:23:31 | 顯示全部樓層 |閱讀模式
  1. Sub Test()
  2.     RangeToHtml Range("A1:C3"), "test.html"
  3. End Sub

  4. Sub RangeToHtml(rng As Range, fileName As String)
  5.     Dim resBeg As String
  6.     resBeg = "<html><head></head><body><table>"
  7.     resEnd = "</table></body></html>"
  8.     For i = 1 To rng.Rows.Count
  9.         '---Rows---
  10.         resBeg = resBeg & "<tr>"
  11.         For j = 1 To rng.Columns.Count
  12.             '---Columns---
  13.             resBeg = resBeg & "<td>"
  14.             resBeg = resBeg & rng.Cells(i, j).Value
  15.             resBeg = resBeg & "</td>"
  16.         Next j
  17.         resBeg = resBeg & "</tr>"
  18.     Next i
  19.     Call SaveStringToFile(resBeg & resEnd, fileName)
  20. End Sub

  21. Sub SaveStringToFile(str As String, fileName As String)
  22.     Open fileName For Output As #1
  23.     Print #1, str
  24.     Close #1
  25. End Sub
複製代碼

資料來源: http://analystcave.com/excel-export-excel-to-html-convert-tables-html/
回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

 ㄚ母滴雞湯
 員林香純滴雞精

Archiver|手機版|小黑屋|彰化一整天的論壇(Excel,Office)  |网站地图

GMT+8, 2018-2-25 15:36 , Processed in 0.107148 second(s), 11 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表