cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with charset in Excel download file

Former Member
0 Kudos

Hi,

in my WD application I have got a FileDownload UI-Element. An IWDResource from the context and an IWDInputStream are used to define the file and provide the data for the download. This is done just like described in the article "Exporting table data using On-Demand Streams."

Problem: Downloaded Excel or HTML files show wrong special characters e.g. German "Umlaute". This looks quite like a charset problem.

The content for the file comes from a String (let's say created using a StringBuffer or a StringWriter). It contains TAB separated values for the Excel.

I tried to build the IWDInputStream like this:

IWDResourceFactory.createInputStream(stringContent);

IWDResourceFactory.createInputStream(stringContent.getBytes("UTF-8"));

IWDResourceFactory.createInputStream(stringContent.getBytes("iso-8859-1"));

The Excel file looks different but not correct in all cases. e.g. instead of 'ü' there is 'u?'.'

What I also did to get more information:

I used a simple J2EE servlet to write the same content to a client.

There it is possible to set the charset: HTTPServletResponse::setContentType("application/vmd.ms-ecxel; charset=utf-8")

This looks ok in Excel.

Anybody got a hint? Do I have to explicitly set the charset somewhere?

Best regards

Ingo

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

I found some more details on my problem:

The encoding of the output is not recognized correctly.

I tried to stream the output to HTML (instead of XLS). The rendering in the browser is also not correct, because the charset is not detected correctly. After selecting View > Encoding > UTF-8 the browser displays ok.

Next thought: In a standard Java servlet it would be possible to specify:

response.setContentType("text/html; charset=utf-8");

I guess it is needed to set the content charset of the Web Dynpro output in a similar way.

But I don't know how to do it...

Regards

Ingo

Former Member
0 Kudos

Remove this line

IWDResourceFactory.createInputStream(stringContent.getBytes("UTF-8"));

and try.. working for me for French.

Rahul

Former Member
0 Kudos

Hi Rahul,

thank you for your reply.

I tried all three createInputStream lines separately. So I removed the charset parameter but of course I can't remove the whole line.

What do you mean by working in French? Other special characters like é and á are also not displayed properly.

Best regards

Ingo

Former Member
0 Kudos

Hi Ingo,

yes French accent, all the French characters are generated/displayed properly.

Rahul

Former Member
0 Kudos

To summarize:

In my scenario German special characters

as well as French accent chars are not correctly displayed in the Excel output.

My question: What can I change or try to fix this?

Regards

Ingo

Former Member
0 Kudos

Hi Martin,

I am downloding as CSV file using below line to convert into correct accent.

excelOnDemandStream =

WDResourceFactory.createInputStream(gocmDownLoadFOrmat(tableDataNode, tableColumnInfos).getBytes("ISO-8859-1"));