[
https://issues.apache.org/jira/browse/FREEMARKER-210?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17607482#comment-17607482
]
Elivs Rong commented on FREEMARKER-210:
---------------------------------------
The Test Code like this:
{code:java}
//代码占位符
try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new
FileOutputStream("D:/freemarker_test/dd12233.xls"), "utf-8"));){
Configuration configuration = new Configuration(new Version("2.3.29"));
configuration.setDefaultEncoding("UTF-8");
configuration.setDirectoryForTemplateLoading(new
File("D:/freemarker_test/"));
Template template = configuration.getTemplate("new1.ftl");
HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
objectObjectHashMap.put("username","world");
template.process(objectObjectHashMap,writer);
writer.flush();
}catch (Exception e){
log.error("in error:{}",e);
} {code}
> Use freemarker to export Excel files. After opening Excel files in Office,
> you will always be prompted "The file format and extension name do not match.
> The file may be damaged or unsafe"
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: FREEMARKER-210
> URL: https://issues.apache.org/jira/browse/FREEMARKER-210
> Project: Apache Freemarker
> Issue Type: Bug
> Components: engine
> Affects Versions: 2.3.29
> Environment: springboot + freemarker(2.3.31) + office(2010或2021)
> Reporter: Elivs Rong
> Priority: Major
> Attachments: image-2022-09-21-11-35-14-194.png
>
>
> {*}Use freemarker to export Excel files. After opening Excel files in
> Office{*}, you will always be prompted "The file format and extension name do
> not match. The file may be damaged or unsafe", like this:
>
> !image-2022-09-21-11-35-14-194.png!
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)