jxlsteam / jxls

Java library for creating Excel reports using Excel templates
http://jxls.sourceforge.net
Apache License 2.0
405 stars 92 forks source link

Do tags in Excel support Chinese characters? If so, how should they be represented? #320

Open hexin-666 opened 5 months ago

hexin-666 commented 5 months ago

I get an error when using ${中文}, and when using ${"中文"}, the data fills with the literal string "中文" instead of the actual data.

hexin-666 commented 5 months ago

i used jxls-2.14.0

gastendonk commented 5 months ago

I use only Latin script. So I don't know!

Everything inside ${..} is a JEXL expression. So this question is Apache JEXL specific and you should ask the JEXL team. Maybe you can debug if the encoding from Java code to JEXL is correct.

@leonate Do you know if Russian characters are possible?

hexin-666 commented 5 months ago

image

The JEXL encoding is correct. Below is the result of setting the label to ${"部门"}. The lastMatchEvalResult should be the actual filled value from the matching Map, but after the method in the red box, lastMatchEvalResult = "部门" instead of the actual value "总部门".

gastendonk commented 5 months ago

I suggest that you debug it with the master version of Jxls and debug deeper. Starting with Jxls version 3.0 you have a better chance to modify the Jxls code if necessary (ExpressionEvaluatorContext.evaluateRawExpression()).

hexin-666 commented 5 months ago

image First of all, thank you for your response and assistance.

I modified line 297 of CellData as shown in the image to support Chinese. The format for Chinese labels is: ${部门}. However, the dynamic table must be in the format ${xx.xx}. Additionally, version 2.14.0 supports labels in the format ${xx."部门"}.

Finally, I would like to express my sincere gratitude once again for your response and help.

SoltauFintel commented 5 months ago

I this a question or can this issue be closed? I would not change it that way.

leonate commented 5 months ago

@leonate Do you know if Russian characters are possible? Don't know, would need to try.