Displaytag正在将CSV导出到.xls文件 [英] Displaytag is exporting CSV into a .xls file

查看:69
本文介绍了Displaytag正在将CSV导出到.xls文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我导出带有DisplayTag的Excel文档.它将另存为.xls文件到我的桌面.当我使用Excel打开它时,显示此错误:

I export an Excel document with DisplayTag. It saves as a .xls file to my Desktop. When I open it with Excel, this error displays:

您要打开的文件'filename.xls'的格式与文件扩展名所指定的格式不同.打开文件之前,请确保该文件未损坏且来自受信任的源."

"The file you are trying to open, 'filename.xls', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file."

如果我单击是",它在Excel中显示就很好.如果我使用Textpad打开它,我会看到它是一个二进制文件,但看起来只是.".分隔字符串.

If I click "Yes", it displays just fine in Excel. If I open this with Textpad, I see that it's a binary file, but it appears to just be "." delimited strings.

任何想法我可能做错了什么,或者下一步如何调试它?

Any ideas what I might have done wrong, or how next to debug this?

:

如果我将扩展名更改为.txt,则它不是二进制文件;这只是一个带分隔符的字符串列表.

If I change the extension to .txt, it's not a binary file; it's simply a list of delimited strings.

推荐答案

Excel的默认导出类设置为CSV类,但扩展名为.xls.更改displaytag.properties是此处的关键,例如:

The default export class for Excel was set to the CSV class, but giving it the .xls extension. Changing displaytag.properties was the key here, something like:

export.types=csv excel xml rtf pdf 
export.excel=true
export.xml=true
export.csv=true
export.rtf=false
export.pdf=false
export.excel.class=org.displaytag.export.excel.DefaultHssfExportView
export.pdf.class=org.displaytag.export.DefaultPdfExportView
export.rtf.class=org.displaytag.export.DefaultRtfExportView
export.excel.filename=data.xls
export.pdf.filename=data.pdf
export.xml.filename=data.xml
export.csv.filename=data.csv
export.rtf.filename=data.rtf

这篇关于Displaytag正在将CSV导出到.xls文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆