---
title: "Excel保存"
author: "aazham"
date: "2012-03-16T20:52:20Z"
tags: []
categories: ["编程语言"]
slug: "excel"
draft: false
lastmod: "2012-03-16T20:56:00Z"
id: 1455597
url: "https://aazham.iteye.com/blog/1455597"
---

设置 Header Content-disposition 可以
如果设置为 attachment 就下载
如果设置为 inline 就直接打开

response.setContentType("application/msexcel");
加上
response.setHeader("Content-disposition", "attachment; filename=\"export.xls\"");
或
response.setHeader("Content-disposition", "inline; filename=\"export.xls\""); 


导出excel时在Servlet中设置
response.setContentType("application/x-download");
response.setHeader("Content-Disposition", "attachment;filename="
				+ fileName + ".xls");