Parse Error / Two Much WhiteSpace

I just want to open an excel file from my VB.NET app but i get a strict parse error saying that it is too much whitespace, any help on what i should do would be fantastic.

i have this in my btnclick function

Dim tw As StreamWriter = New StreamWriter("C:\book1.xml.")

tw.WriteLine("

< xml version=""1.0"" >" & _

"<Workbook xmlns=""urn:schemas-microsoft-com:office:spreadsheet""" & _

"xmlns: o = ""urn:schemas-microsoft-com:office:office""" & _

"xmlns: x = ""urn:schemas-microsoft-com:office:excel""" & _

"xmlns: ss = ""urn:schemas-microsoft-com:office:spreadsheet""" & _

"xmlns:html=""http://www.w3.org/TR/REC-html40"">" & _

"<DocumentProperties xmlns=""urn:schemas-microsoft-com:office:office"">" & _

"<Author>Mr. Powers</Author>" & _

"<LastAuthor>Mr. Powers</LastAuthor>" & _

" <Created>2006-02-12T15:36:44Z</Created>" & _

"<Version>10.3501</Version>" & _

"</DocumentProperties>" & _

"<ExcelWorkbook xmlns=""urn:schemas-microsoft-com:office:excel"">" & _

" <WindowHeight>9345</WindowHeight>" & _

" <WindowWidth>15180</WindowWidth>" & _

" <WindowTopX>120</WindowTopX>" & _

"<WindowTopY>45</WindowTopY>" & _

"<ProtectStructure>False</ProtectStructure>" & _

"<ProtectWindows>False</ProtectWindows>" & _

"</ExcelWorkbook>" & _

"<Styles>" & _

"<Style ss:ID=""Default"" ss:Name=""Normal"">" & _

"<Alignment ss:Vertical=""Bottom""/>" & _

"<Borders/>" & _

"<Font/>" & _

"<Interior/>" & _

"<NumberFormat/>" & _

"<Protection/>" & _

"</Style>" & _

"</Styles>" & _

"<Worksheet ss:Name=""Sheet1"">" & _

"<WorksheetOptions xmlns=""urn:schemas-microsoft-com:office:excel"">" & _

"<Selected/>" & _

"<ProtectObjects>False</ProtectObjects>" & _

" <ProtectScenarios>False</ProtectScenarios>" & _

"</WorksheetOptions>" & _

"</Worksheet>" & _

"<Worksheet ss:Name=""Sheet2"">" & _

"<WorksheetOptions xmlns=""urn:schemas-microsoft-com:office:excel"">" & _

" <ProtectObjects>False</ProtectObjects>" & _

" <ProtectScenarios>False</ProtectScenarios>" & _

"</WorksheetOptions>" & _

"</Worksheet>" & _

"<Worksheet ss:Name=""Sheet3"">" & _

"<WorksheetOptions xmlns=""urn:schemas-microsoft-com:office:excel"">" & _

"<ProtectObjects>False</ProtectObjects>" & _

"<ProtectScenarios>False</ProtectScenarios>" & _

"</WorksheetOptions>" & _

"</Worksheet>" & _

"</Workbook>")

tw.Close()

End Sub

End Class

 




Answer this question

Parse Error / Two Much WhiteSpace

  • Krystan Honour

    There should be at least one space before 'xmlns:', and no spaces between 'xmlns:' and a prefix:

    " xmlns:o=""urn:schemas-microsoft-com:office:office""" & _
    " xmlns:x=""urn:schemas-microsoft-com:office:excel""" & _
    " xmlns:ss=""urn:schemas-microsoft-com:office:spreadsheet""" & _
    " xmlns:html=""
    http://www.w3.org/TR/REC-html40"">" & _

    Also you probably want to insert < mso-application progid="Excel.Sheet" > processing instruction right after < xml... >.

    Best regards,
    Anton


  • Parse Error / Two Much WhiteSpace