开发者

Set encoding for Apache POI excel workbook

I'm using the Apache POI library to create, and fill an excel sheet in C# .NET.

The problem I'm faced with however, is that the data I populate my workbook with, contains some special character开发者_JS百科s (e.g. é, á, í, etc). I have been told that I need to create the worksheet with UTF-8 encoding in order for our partners to be able to auto ingest these excel files.

Does anyone who has experience using the POI library know how to set this value?


Apache POI is normally used from Java, so I don't know if the fact that you're using C# is affecting things or not...

If you were using POI in pure Java, then you simply create a Java String with your characters in it as normal. Next, pass that String to POI when setting the cell contents. POI will either store the text as ASCII or Unicode depending on the contents, and you don't need to do anything. (The encoding is all handled for you)

I'd suggest you ensure that you're creating the string properly with the international characters in it, then try passing that string to POI and see what happens. Hopefully C# will behave the same as Java and you'll be fine!

(If not, you might need to look into your C# / Java bridge, since as long as the right Unicode strings turn up in Java then POI should be correctly handling all the encoding stuff for you)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜