Import data from Excel file in Silverlight application -


i using vs2010, silverlight 5.0

i trying import data excel file grid, using 'openfiledialog'. user can input excel file using openfiledialog this

openfiledialog dlg = new openfiledialog(); dlg.multiselect = false; dlg.filter = "excel sheet(*.xls)|*.xls|all files(*.*)|*.*"; bool bresult = (bool)dlg.showdialog(); if (!bresult)     return "";  fileinfo info = dlg.file; statustext.text = info.name;  stream s = info.openread(); streamreader reader = new streamreader(s); string xml = reader.readtoend(); var doc = xdocument.parse(xml); 

in case of microsoft excel format 2003 or 2007(.xls file) above code works fine , gives me values excel in string.

but in case of microsoft excel format 2010(.xlsx file) reader.readtoend() not return values in proper format next line, give me following error.

var doc = xdocument.parse(xml); 'data @ root level invalid. line 1, position 1' 

how can solve error, or best way import data excel?


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -