mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-05 05:07:58 +08:00
🚩 新增操作excel时快速获取Content-Type的方法
This commit is contained in:
parent
0f5133013d
commit
4ee9c2cb08
@ -25,6 +25,16 @@ import java.io.InputStream;
|
|||||||
*/
|
*/
|
||||||
public class ExcelUtil {
|
public class ExcelUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xlx的ContentType
|
||||||
|
*/
|
||||||
|
public static final String XLS_CONTENT_TYPE = "application/vnd.ms-excel;charset=utf-8";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xlsx的ContentType
|
||||||
|
*/
|
||||||
|
public static final String XLSX_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8";
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------ Read by Sax start
|
// ------------------------------------------------------------------------------------ Read by Sax start
|
||||||
/**
|
/**
|
||||||
* 通过Sax方式读取Excel,同时支持03和07格式
|
* 通过Sax方式读取Excel,同时支持03和07格式
|
||||||
|
@ -382,6 +382,19 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
|
|||||||
return StrUtil.format("attachment; filename=\"{}\"; filename*={}''{}", fileName, charset.name(), fileName);
|
return StrUtil.format("attachment; filename=\"{}\"; filename*={}''{}", fileName, charset.name(), fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Content-Type头对应的值,可以通过调用以下方法快速设置下载Excel的头信息:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* response.setContentType(excelWriter.getContentType());
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @return Content-Type值
|
||||||
|
*/
|
||||||
|
public String getContentType() {
|
||||||
|
return isXlsx() ? ExcelUtil.XLSX_CONTENT_TYPE : ExcelUtil.XLS_CONTENT_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置当前所在行
|
* 设置当前所在行
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user