question

JeheonKim-1762 avatar image
0 Votes"
JeheonKim-1762 asked Viorel-1 answered

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

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.

dotnet-visual-basic
image.png (57.4 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Viorel-1 avatar image
0 Votes"
Viorel-1 answered

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).


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.