Как выделить столбец при переводе из Экселя в html?

Из таблицы Экселя:
1	04:56	06:25	12:09	15:11	17:47	18:58
2	04:55	06:24	12:09	15:12	17:48	18:59
3	04:53	06:22	12:09	15:12	17:49	19:00
4	04:52	06:20	12:09	15:13	17:50	19:01
5	04:50	06:19	12:09	15:14	17:51	19:02


перевожу в HTML:
Sub ExportExcelTableToHTML()
    
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set f = FSO.CreateTextFile("export.html", True)
    
    Dim rInput As Range
    Dim rRow As Range
    Dim rCell As Range
    Dim strReturn As String
    
    Set rInput = Range("A1:G31")
    
    'Define table format and font
    strReturn = "<div class=""show-for-medium""> "
    
    strReturn = strReturn & "<table class=""table table-striped"">  "
    
    strReturn = strReturn & "<thead> <tr> <th>День</th> <th>Утро</th> <th class=""voshod"">Восход</th> <th>Обеденный</th> <th>Аср</th> <th>Вечерний</th> <th>Ночной</th> </tr> </thead> "
    
    strReturn = strReturn & "<tbody>"
    
    'Loop through each row in the range
    For Each rRow In rInput.Rows
        'Start new html row
        strReturn = strReturn & "<tr> "
        For Each rCell In rRow.Cells
            strReturn = strReturn & "<td>" & rCell.Text & "</td>"
        Next rCell
        'End a row
        strReturn = strReturn & "</tr>"
    Next rRow
    
    strReturn = strReturn & "</tbody>"
    
    strReturn = strReturn & "</table>"
    
    strReturn = strReturn & "</div> "

    f.WriteLine (strReturn)
End Sub


Дата	Утренний	Восход солнца	Обеденный	Аср	Вечерний	Ночной
1	04:56	06:25	12:09	15:11	17:47	18:58
2	04:55	06:24	12:09	15:12	17:48	18:59
3	04:53	06:22	12:09	15:12	17:49	19:00
4	04:52	06:20	12:09	15:13	17:50	19:01
5	04:50	06:19	12:09	15:14	17:51	19:02


Не знаю, как к третьему столбцу добавить стиль:
<td class="voshod">07:03</td>
получив именно такую HTML-таблицу:
<tr>
               <td>1</td>
               <td>04:56</td>
               <td class="voshod">06:25</td>
               <td>12:09</td>
               <td>15:11</td>
               <td>17:47</td>
               <td>18:58</td>
            </tr>
  • Вопрос задан
  • 38 просмотров
Пригласить эксперта
Ответы на вопрос 1
wisgest
@wisgest
Не ИТ-специалист
Можете создать объект HTMLFile:
Set htmldoc = CreateObject("HTMLFile")
и работать с ним как документом HTML:
Set htmltable = htmldoc.createElement("TABLE")
MsgBox htmltable.outerHTML

Рекомендуемые поисковые запросы:
"htmlfile" site:script-coding.com,
CreateObject HTMLFile.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы