on 09-12-2008 10:37 AM
Hi All,
I am using [https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/3596] [original link is broken] [original link is broken] [original link is broken]; Blog for exporting data into the Excel file.
But i am getting error whenever my text contains special characters like &
The export is failed when this type of special characters are coming
So how can i remmove this type of errors
So pls help me...asap.
Thanks & Regards,
Dhruv Shah
Hi,
I guess the error you are getting is a Parser error. To solve this problem, before putting the data on the XML file, you have to pass the data through an encoding process. For UTF-8 the code for encoding should be something like.
public java.lang.String encodeSpecialChar( java.lang.String attributeValue )
{
//@@begin encodeSpecialChar()
//Created By : AVIK SANYAL Date : 28 March 2008.
// Check for special characters like "&" in the String.
// replace "&" with "&"
// Returns the new encoded String.
try {
if (attributeValue != null) {
attributeValue = attributeValue.replaceAll("&", "&");
attributeValue = attributeValue.replaceAll("<", ""<"");// this is & lt
attributeValue = attributeValue.replaceAll(">", "">"");//this is & gt
} else {
}
} catch (Exception ex) {
// wdComponentAPI.getMessageManager().reportException(
// "Failed to convert the character.",
// true);
}
//Returns the encoded String.
return attributeValue;
//@@end
}
Try this and let me know if this works. The reason is that in Binary Cache method, the data is passed in an XML format and the MS-Excel application reads this to show it in the spreadsheet. The characters '&', '<' and '>' can cause failure in reading from this file.
Thank You
Avik
Edited by: AVIK SANYAL on Sep 12, 2008 10:45 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
O ho..... My mistake in typing.....
Add a semi colon after &
Edited by: AVIK SANYAL on Sep 12, 2008 2:08 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What seems to be the problem Dhruv?????
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have an idea...... To check if the solution works........
Replace the & with & in the Wordpad and then Save it as .xls file.
Try to open the saved file with MS-Excel. That should solve the problem.
If you get further errors....... Try to replace the strings with proper encoded characters.......
Then open the file in MS-Excel.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Then you have to pass the data through the encoding code that I have sent you. That will convert the & to & and the problem will be solved.
If you need any help then do not hesitate.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
OK....!!!!!
just download the Excel file (*.xls) and try open with Word-MS. In the document search by the string that you have mentioned in the question. (Use Ctrl +F).
If you see something like "ABC bla bla ba & instead of & , then you have to pass the data through the code I've mentioned.
You can get more details on encoding special characters UTF-8 in Google.com or Sun Websites etc.
You can also encode the & in hexadecimal format to get the desired output.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.