How to read Row Height from the Excel table in XML format? (VB.NET)

DS_Veritas 21 Reputation points
2021-07-06T08:50:00.637+00:00

112151-image.png

Hello.

I am trying to retrieve some values from the Excel table in XML format and need some help.

The values under the Table section, such as "ExpandedColumnCount" and "ExpandedRowCount", can be obtained:

Dim spreadSheet = New System.Data.DataSet
spreadSheet.ReadXml(CType(data.GetData("XML Spreadsheet"), System.IO.Stream))

Dim rowCount As Integer = CInt(Int(spreadSheet.Tables("Table").Rows(0)("ExpandedRowCount")))
Dim columnCount As Integer = CInt(Int(spreadSheet.Tables("Table").Rows(0)("ExpandedColumnCount")))

However, I am having trouble accessing the row height values under the Table section.
I am aware that there will be no assigned values unless the height for each row is customized.

So, assuming that the first row has the customized height, how can I retrieve this value?

Thanks in advance.

Developer technologies | VB
0 comments No comments
{count} votes

Answer accepted by question author
  1. Viorel 125.7K Reputation points
    2021-07-06T11:08:11.793+00:00

    To get the height of first row, try processing the XML content, for example:

    Dim x As New XmlDocument
    x.Load(CType(data.GetData("XML Spreadsheet"), System.IO.Stream))
    
    Dim m As New XmlNamespaceManager(x.NameTable)
    m.AddNamespace("ss", "urn:schemas-microsoft-com:office:spreadsheet")
    
    Dim h = x.SelectSingleNode("/ss:Workbook/ss:Worksheet[@ss:Name='Sheet1']/ss:Table/ss:Row/@ss:Height", m)?.Value
    

    Then you can cast h to Double using CDbl(h).

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.