This project has moved. For the latest updates, please go here.

Adding HTML using QueryTables

Apr 18, 2012 at 4:59 PM

Hi, 

First, I would like to thank you for developing this great API - It is very helpfull !

Second, I'm trying to transf a xls generation from a VB6 code that inserts a HTML content in the following way :

Private Sub InsertHTML(ByVal htmlPath As String, ByRef aSheet As Excel.Worksheet, Optional ByVal Row As Integer = 1)
Dim aTable As Excel.QueryTable
Dim aRange As Excel.Range
    On Error Resume Next
    Set aRange = aSheet.Range("A" & CStr(Row))
    Set aTable = aSheet.QueryTables.Add("URL;file:///" & htmlPath, aRange)
    With aTable
        .name = aSheet.name
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = False
        .RefreshOnFileOpen = False
        .BackgroundQuery = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = False
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlEntirePage
        .WebFormatting = xlWebFormattingAll
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = True
        .Refresh False
        .Delete
    End With
End Sub

Is there a way to do the same with your API ?

Thanks !

Coordinator
Apr 18, 2012 at 5:05 PM

Nope. Sorry.

Apr 18, 2012 at 5:12 PM

Thanks for the quick response.

How do you recommend adding html content ?

Amir.

Coordinator
Apr 18, 2012 at 5:20 PM

In your case I'd convert the html table(s) to a dataset and then insert the dataset/datatable(s) with ClosedXML.