Thursday, February 10, 2011

VB.NET: Import and Export Excel Data with LINQ to XML

Embedded VB.NET Expressions

In Visual Basic 9.0, an XML literal is considered an expression. If you want to assign a value to an object representing an XML tree, you can simply write that value as an assigned expression, as
follows:

Dim customers = _
From customer In Me.CustomersDataSet.Customers _
Where customer.RowState <> DataRowState.Deleted _
AndAlso Not customer.IsAbbrevNull _
Order By customer.Abbrev _
Select <Row>
<Cell><Data ss:Type="String"><%= customer.Abbrev %></Data></Cell>
<Cell><Data ss:Type="String"><%= If(customer.IsNameNull, "", customer.Name)%> </Data></Cell>
<Cell><Data ss:Type="String"><%= If(customer.IsPhoneNull, "", customer.Phone)%> </Data></Cell>
<Cell><Data ss:Type="String"><%= If(customer.IsCountryNull, "",customer.Country)%> </Data></Cell>
</Row>

VB.NET: Import and Export Excel Data with LINQ to XML

No comments: