Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7627637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:29:09+00:00 2026-05-31T05:29:09+00:00

I try to export some data to Excel using XML. Here is an example

  • 0

I try to export some data to Excel using XML. Here is an example of my code that generates the Excel file:

    Private Sub ExportToExcel()
    Dim fs As New IO.StreamWriter("exported.xls", False)
    fs.WriteLine("<?xml version=""1.0""?>")
    fs.WriteLine("<?mso-application progid=""Excel.Sheet""?>")
    fs.WriteLine("<Workbook xmlns:ss=""urn:schemas-microsoft-com: Office:spreadsheet"">")

    ' Create the styles for the worksheet
    fs.WriteLine(" <Styles>")

    ' Style for the column headers
    fs.WriteLine(" <Style ss:ID=""1"">")
    fs.WriteLine(" <Font ss:Bold=""1""/>")
    fs.WriteLine(" <Alignment ss:Horizontal=""Center"" ss:Vertical=""Center"" " & _
    "ss:WrapText=""1""/>")
    fs.WriteLine(" <Interior ss:Color=""#C0C0C0"" ss:Pattern=""Solid""/>")
    fs.WriteLine(" </Style>")

    ' Style for the column information
    fs.WriteLine(" <Style ss:ID=""2"">")
    fs.WriteLine(" <Alignment ss:Vertical=""Center"" ss:WrapText=""1""/>")
    fs.WriteLine(" </Style>")
    fs.WriteLine(" </Styles>")

    ' Write the worksheet contents
    fs.WriteLine("<Worksheet ss:Name=""Data Export"">")
    fs.WriteLine(" <Table>")

    For i As Integer = 0 To 1
        fs.WriteLine(" <Row>")
        For j As Integer = 0 To 2
            fs.WriteLine(" <Cell>")
            fs.WriteLine(" <Data ss:Type=""String"">H</Data>")
            fs.WriteLine(" </Cell>")
        Next
        fs.WriteLine(" </Row>")
    Next

        ' Close up the document
        fs.WriteLine(" </Table>")
        fs.WriteLine("</Worksheet>")
        fs.WriteLine("</Workbook>")

        fs.Close()

End Sub

And this is what I have in my generated xls file:

    <?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns:ss="urn:schemas-microsoft-com: Office:spreadsheet">
 <Styles>
 <Style ss:ID="1">
 <Font ss:Bold="1"/>
 <Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1"/>
 <Interior ss:Color="#C0C0C0" ss:Pattern="Solid"/>
 </Style>
 <Style ss:ID="2">
 <Alignment ss:Vertical="Center" ss:WrapText="1"/>
 </Style>
 </Styles>
<Worksheet ss:Name="Data Export">
 <Table>
 <Row>
 <Cell>
 <Data ss:Type="String">H</Data>
 </Cell>
 <Cell>
 <Data ss:Type="String">H</Data>
 </Cell>
 <Cell>
 <Data ss:Type="String">H</Data>
 </Cell>
 </Row>
 <Row>
 <Cell>
 <Data ss:Type="String">H</Data>
 </Cell>
 <Cell>
 <Data ss:Type="String">H</Data>
 </Cell>
 <Cell>
 <Data ss:Type="String">H</Data>
 </Cell>
 </Row>
 </Table>
</Worksheet>
</Workbook>

Seems to be correct, but when I open the xls I have a crazy output:enter image description here

But it is not everything: if I write manualy the xml structure to my xsl file (or I copy-paste it from another file for example) the output is ok – I see my rows & columns with right values (H,H,H everywhere), formatting, the name of the worksheet is “Data Export” as I set it… don’t understand 🙁 Please, explain me someone. Thanks a lot!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:29:10+00:00Added an answer on May 31, 2026 at 5:29 am

    Just Replace the line

    fs.WriteLine("<Workbook xmlns:ss=""urn:schemas-microsoft-com: Office:spreadsheet"">")
    

    With

    fs.WriteLine("<Workbook xmlns=""urn:schemas-microsoft-com:office:spreadsheet""")
    fs.WriteLine("xmlns:o=""urn:schemas-microsoft-com:office:office""")
    fs.WriteLine("xmlns:x=""urn:schemas-microsoft-com:office:excel""")
    fs.WriteLine("xmlns:ss=""urn:schemas-microsoft-com:office:spreadsheet"">")
    

    It will resolve the issues

    1. Output of the sheet
    2. Name of the worksheet 
    

    Output File

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using DevExpress Wpf GridControl v2011.2. I try to export data to excel via
I am trying to export some data to Excel. I am using OLEDB 12.
I want to export some data from my jruby on rails webapp to excel,
Can i export a data from a table to an excel sheet, using javascript?
I've got this code I'm trying to use to export data from Excel to
I'm writing a script which pulls out some patient data and generates an XML
I want users to be able to export data as an XML file. Of
I was asked to work on this back-end scheduled job that export some customers
I am trying to create a csv file of some data. I have wrote
I am using Memory-stream to write my data into Excel (used Unicode8F),however i have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.