having problem in writing the character '&' in word doc , by using open xml sdk
-
Friday, May 04, 2012 12:00 PM
Dear All,
I have made this xml to fill out the word template by using offcourse open xml sdk
string newXML = "<root>" +
"<AssociateName>"+AssociateName+"</AssociateName>" +
"<EmpID>"+EmpID+"</EmpID>" +
"<GiftAmount>"+GiftAmount+"</GiftAmount>" +
"<GiftDate>"+GiftDate+"</GiftDate>" +
"<HomeStreetAddress>"+HomeStreetAddress+"</HomeStreetAddress>" +
"<NPOName>"+NPOName+"</NPOName>" +
"<CityName>"+CityName+"</CityName>" +
"<StateName>"+StateName+"</StateName>" +
"<ZipCode>"+ZipCode+"</ZipCode>" +
"<NPStreetAddress>"+NPStreetAddress+"</NPStreetAddress>" +
"<WorkEmail>"+WorkEmail+"</WorkEmail>" +
"<NPCity>"+NPCity+"</NPCity>" +
"<NPState>"+NPState+"</NPState>" +
"<NPZipCode>"+NPZipCode+"</NPZipCode>" +
"<WorkPhone>"+WorkPhone+"</WorkPhone>" +
"<DivisionName>" + DivisionName + "</DivisionName>" +
"<LocationName>"+LocationName+"</LocationName>" +
"</root>";the problem i am having is this that DIVISION NAME is " Systems & Services " , (comes from the sql database) and when it does it corrupts the word file and when i open it it says the "Word File cannot be opene dbecause there is a problem with the contents" , so i dig to find out wat content is creating the problem and it turned out to be '&' character is Systems & Services , cause if u remove & char the word file open perfectly with data populated , please help how can i over come this so the '&' char dont creat problem :-(
All Replies
-
Friday, May 04, 2012 1:08 PM
well it turned out to be that i had to replace the '&' with & and then it worked fine so my issue got resolved
here is the link
http://forums.asp.net/p/1800123/4965619.aspx/1?Re+having+problem+in+writing+the+character+in+word+doc+by+using+open+xml+sdk

