grails中的导出插件是否也支持.xlsx格式?我将扩展名称为“xlsx”,内容类型为"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
。
我已经完成了代码并运行它没有任何问题。打开下载的文件时出现问题。该文件不能按原样打开(即使用xlsx扩展名')。如果我将扩展名更改为“xls”,我可以毫无问题地打开它。
@EmmanuelRosa,@ monty_bean
Grails版本:2.0.3 导出插件版本1.5
Grails配置
grails.mime.types = [
html: ['text/html','application/xhtml+xml'],
xml: ['text/xml', 'application/xml'],
text: 'text-plain',
js: 'text/javascript',
rss: 'application/rss+xml',
atom: 'application/atom+xml',
css: 'text/css',
csv: 'text/csv',
pdf: 'application/pdf',
rtf: 'application/rtf',
excel: ['application/vnd.ms-excel','application/vnd.openxmlformats- officedocument.spreadsheetml.sheet'],
ods: 'application/vnd.oasis.opendocument.spreadsheet',
all: '*/*',
json: ['application/json','text/json'],
form: 'application/x-www-form-urlencoded',
multipartForm: 'multipart/form-data'
JS代码:
window.open("${createLink(controller: 'mqdsRequest', action:'exportOpenRequestsData')}", "_blank");
Groovy代码:
List<ExportData> exportData = sObjects?.collect {
new ExportData(mQDSRequestName: it.mQDSRequestName, name: it.name, prodID: it.mQDSRequestr?.prodID, mCNforOracleGainTask: it.mQDSRequestr?.mCNforOracleGainTask,
lotNumberforOracleGainTask: it.mQDSRequestr?.lotNumberforOracleGainTask,
taskType: it.mQDSRequestr?.taskType, currentQuantity: it.mQDSRequestr?.currentQuantity, routeInformation: it.mQDSRequestr?.routeInformation,
onHoldReason: it.mQDSRequestr?.onHoldReason, bakeOut: formatDate(date:it.bakeOut, format: 'MM/dd/yyyy hh:mm a',timeZone: 'PST'),
taskCompletion: formatDate(date:it.taskCompletion, format: 'MM/dd/yyyy hh:mm a',timeZone: 'PST'),
taskStatus: it.taskStatus, tISRequestor: it.mQDSRequestr?.tISRequestorr?.name, bakeTime: it.bakeTime, plannerPriority: it.mQDSRequestr?.plannerPriority)
}
Map parameters = ["column.widths": Holders.config.standalone.rmaonly.export.file.column.widths]
exportService.export(fileType, response, fileName, fileExtension, exportData-null, new ArrayList<String>(HEADERS_COLUMNS_STANDALONE_TASKS_RMA_ONLY.keySet()), HEADERS_COLUMNS_STANDALONE_TASKS_RMA_ONLY, [:], parameters)
这里,文件名类似'BakeStandalonewithRMA = Yes_03022016,0926AMPST' 的fileType ='Excel的 fileExtension = 'XLSX'