hi i want to pass axcel sheet as xml to my store procedure..i was doing this by getting values in data table and then convetring that data table to exml..but i found when when i add a line at the end of sheet and then delete that ..even than when my sheet
is loaded in data table it gives me blank rows at end which cause error in my case.i want to avoid that error.
so want to know some easy and direct way to convert excel to xml or some way to avoid those blank lines.
but i found when when i add a line at the end of sheet and then delete that ..even than when my sheet is loaded in data table it gives me blank rows at end which cause error in my case.i want to avoid that error.
When do you do that?Do you mean you do that after make a connection to the Excel file successfully and you change the excel file??
no i was adding and deleting before uploding... but still it was picking some empty rows at the end.
That's a little strange——Well,you can check whether your string.IsNullOrEmpty(DataTable.Rows[index][Field-index])。If yes,delete the whole row;after doing this and submit……:-)
Marked as answer by shumailaAjk on Mar 14, 2012 09:31 AM
shumailaAjk
Member
620 Points
380 Posts
how to get excel data as xml in c# code
Mar 12, 2012 09:23 AM|LINK
hi i want to pass axcel sheet as xml to my store procedure..i was doing this by getting values in data table and then convetring that data table to exml..but i found when when i add a line at the end of sheet and then delete that ..even than when my sheet is loaded in data table it gives me blank rows at end which cause error in my case.i want to avoid that error.
so want to know some easy and direct way to convert excel to xml or some way to avoid those blank lines.
Sum8
Contributor
4141 Points
931 Posts
Re: how to get excel data as xml in c# code
Mar 12, 2012 09:30 AM|LINK
Refer this post: http://forums.asp.net/t/1598497.aspx/1
Sumit Pathak
------------------
ThisPost = Helped == True ? "Mark As Answer" : "Elaborate your problem in more details"
d4daud
Contributor
2293 Points
468 Posts
Re: how to get excel data as xml in c# code
Mar 12, 2012 09:44 AM|LINK
http://forums.asp.net/t/1448348.aspx/1
http://www.codeproject.com/Articles/10581/Convert-Excel-to-XML-file-XML-Schema-and-validate
shumailaAjk
Member
620 Points
380 Posts
Re: how to get excel data as xml in c# code
Mar 12, 2012 10:30 AM|LINK
can't i add criteria here when selecting from excel sheet
select * from [Sheet1$] ??
i dont want to select every thing from excel sheet.i want to apply a check like if column one value is empty then skip that
is something like this is possible here??
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: how to get excel data as xml in c# code
Mar 14, 2012 01:36 AM|LINK
When do you do that?Do you mean you do that after make a connection to the Excel file successfully and you change the excel file??
shumailaAjk
Member
620 Points
380 Posts
Re: how to get excel data as xml in c# code
Mar 14, 2012 04:40 AM|LINK
NO this was happining when i update my excel sheet supose i add two more records first save that
then i delete those two records and save my excel sheet..now when i was trying to upload that sheet it gives two empty lines at the end
those empty lines were creating problem for me.now i manage this by changing my query like this
select * from [Sheet1$] where sap_id is not null
so now i m not facing that issue.:-)
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: how to get excel data as xml in c# code
Mar 14, 2012 04:51 AM|LINK
So you mean this happens when you:
1)upload an original excel file onto Server。
2)Add rows。
3)Delete rows。
4)Read them out,and found two empty rows?
shumailaAjk
Member
620 Points
380 Posts
Re: how to get excel data as xml in c# code
Mar 14, 2012 05:43 AM|LINK
no i was adding and deleting before uploding... but still it was picking some empty rows at the end.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: how to get excel data as xml in c# code
Mar 14, 2012 06:31 AM|LINK
That's a little strange——Well,you can check whether your string.IsNullOrEmpty(DataTable.Rows[index][Field-index])。If yes,delete the whole row;after doing this and submit……:-)
shumailaAjk
Member
620 Points
380 Posts
Re: how to get excel data as xml in c# code
Mar 14, 2012 09:31 AM|LINK
:-) it is really strange.but its really hapening. thanks for solution