mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-08-18 20:38:02 +08:00
add contenttype
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# 5.6.7 (2021-06-07)
|
# 5.6.7 (2021-06-08)
|
||||||
|
|
||||||
### 🐣新特性
|
### 🐣新特性
|
||||||
* 【core 】 CharSequenceUtil增加join重载(issue#I3TFJ5@Gitee)
|
* 【core 】 CharSequenceUtil增加join重载(issue#I3TFJ5@Gitee)
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
* 【core 】 CsvConfig的setXXX返回this(issue#I3UIQF@Gitee)
|
* 【core 】 CsvConfig的setXXX返回this(issue#I3UIQF@Gitee)
|
||||||
* 【all 】 增加jmh基准测试
|
* 【all 】 增加jmh基准测试
|
||||||
* 【core 】 增加StreamUtil和CollectorUtil
|
* 【core 】 增加StreamUtil和CollectorUtil
|
||||||
|
* 【poi 】 增加content-type(pr#1639@Github)
|
||||||
|
|
||||||
### 🐞Bug修复
|
### 🐞Bug修复
|
||||||
* 【core 】 修复FileUtil.normalize去掉末尾空格问题(issue#1603@Github)
|
* 【core 】 修复FileUtil.normalize去掉末尾空格问题(issue#1603@Github)
|
||||||
|
@@ -21,21 +21,21 @@ import java.io.InputStream;
|
|||||||
* Excel工具类,不建议直接使用index直接操作sheet,在wps/excel中sheet显示顺序与index无关,还有隐藏sheet
|
* Excel工具类,不建议直接使用index直接操作sheet,在wps/excel中sheet显示顺序与index无关,还有隐藏sheet
|
||||||
*
|
*
|
||||||
* @author Looly
|
* @author Looly
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ExcelUtil {
|
public class ExcelUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xlx的ContentType
|
* xlx的ContentType
|
||||||
*/
|
*/
|
||||||
public static final String XLS_CONTENT_TYPE = "application/vnd.ms-excel;charset=utf-8";
|
public static final String XLS_CONTENT_TYPE = "application/vnd.ms-excel";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xlsx的ContentType
|
* xlsx的ContentType
|
||||||
*/
|
*/
|
||||||
public static final String XLSX_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8";
|
public static final String XLSX_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------ Read by Sax start
|
// ------------------------------------------------------------------------------------ Read by Sax start
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过Sax方式读取Excel,同时支持03和07格式
|
* 通过Sax方式读取Excel,同时支持03和07格式
|
||||||
*
|
*
|
||||||
@@ -230,6 +230,7 @@ public class ExcelUtil {
|
|||||||
// ------------------------------------------------------------------------------------ Read by Sax end
|
// ------------------------------------------------------------------------------------ Read by Sax end
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------ getReader
|
// ------------------------------------------------------------------------------------------------ getReader
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取Excel读取器,通过调用{@link ExcelReader}的read或readXXX方法读取Excel内容<br>
|
* 获取Excel读取器,通过调用{@link ExcelReader}的read或readXXX方法读取Excel内容<br>
|
||||||
* 默认调用第一个sheet
|
* 默认调用第一个sheet
|
||||||
@@ -397,6 +398,7 @@ public class ExcelUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------ getWriter
|
// ------------------------------------------------------------------------------------------------ getWriter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得{@link ExcelWriter},默认写出到第一个sheet<br>
|
* 获得{@link ExcelWriter},默认写出到第一个sheet<br>
|
||||||
* 不传入写出的Excel文件路径,只能调用ExcelWriter#flush(OutputStream)方法写出到流<br>
|
* 不传入写出的Excel文件路径,只能调用ExcelWriter#flush(OutputStream)方法写出到流<br>
|
||||||
@@ -453,7 +455,7 @@ public class ExcelUtil {
|
|||||||
*/
|
*/
|
||||||
public static ExcelWriter getWriterWithSheet(String sheetName) {
|
public static ExcelWriter getWriterWithSheet(String sheetName) {
|
||||||
try {
|
try {
|
||||||
return new ExcelWriter((File)null, sheetName);
|
return new ExcelWriter((File) null, sheetName);
|
||||||
} catch (NoClassDefFoundError e) {
|
} catch (NoClassDefFoundError e) {
|
||||||
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
|
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
|
||||||
}
|
}
|
||||||
@@ -504,6 +506,7 @@ public class ExcelUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------ getBigWriter
|
// ------------------------------------------------------------------------------------------------ getBigWriter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得{@link BigExcelWriter},默认写出到第一个sheet<br>
|
* 获得{@link BigExcelWriter},默认写出到第一个sheet<br>
|
||||||
* 不传入写出的Excel文件路径,只能调用ExcelWriter#flush(OutputStream)方法写出到流<br>
|
* 不传入写出的Excel文件路径,只能调用ExcelWriter#flush(OutputStream)方法写出到流<br>
|
||||||
@@ -647,9 +650,9 @@ public class ExcelUtil {
|
|||||||
* @return 坐标点,x表示行,从0开始,y表示列,从0开始
|
* @return 坐标点,x表示行,从0开始,y表示列,从0开始
|
||||||
* @since 5.1.4
|
* @since 5.1.4
|
||||||
*/
|
*/
|
||||||
public static CellLocation toLocation(String locationRef){
|
public static CellLocation toLocation(String locationRef) {
|
||||||
final int x = colNameToIndex(locationRef);
|
final int x = colNameToIndex(locationRef);
|
||||||
final int y = ReUtil.getFirstNumber(locationRef) -1;
|
final int y = ReUtil.getFirstNumber(locationRef) - 1;
|
||||||
return new CellLocation(x, y);
|
return new CellLocation(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -390,6 +390,7 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
|
|||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @return Content-Type值
|
* @return Content-Type值
|
||||||
|
* @since 5.6.7
|
||||||
*/
|
*/
|
||||||
public String getContentType() {
|
public String getContentType() {
|
||||||
return isXlsx() ? ExcelUtil.XLSX_CONTENT_TYPE : ExcelUtil.XLS_CONTENT_TYPE;
|
return isXlsx() ? ExcelUtil.XLSX_CONTENT_TYPE : ExcelUtil.XLS_CONTENT_TYPE;
|
||||||
@@ -408,10 +409,11 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 定位到最后一行的后边,用于追加数据
|
* 定位到最后一行的后边,用于追加数据
|
||||||
|
*
|
||||||
* @return this
|
* @return this
|
||||||
* @since 5.5.0
|
* @since 5.5.0
|
||||||
*/
|
*/
|
||||||
public ExcelWriter setCurrentRowToEnd(){
|
public ExcelWriter setCurrentRowToEnd() {
|
||||||
return setCurrentRow(getRowCount());
|
return setCurrentRow(getRowCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -892,8 +894,8 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
|
|||||||
* @param rowData 一行的数据
|
* @param rowData 一行的数据
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
public ExcelWriter writeSecHeadRow(Iterable<?> rowData){
|
public ExcelWriter writeSecHeadRow(Iterable<?> rowData) {
|
||||||
final Row row = RowUtil.getOrCreateRow(this.sheet,this.currentRow.getAndIncrement());
|
final Row row = RowUtil.getOrCreateRow(this.sheet, this.currentRow.getAndIncrement());
|
||||||
Iterator<?> iterator = rowData.iterator();
|
Iterator<?> iterator = rowData.iterator();
|
||||||
//如果获取的row存在单元格,则执行复杂表头逻辑,否则直接调用writeHeadRow(Iterable<?> rowData)
|
//如果获取的row存在单元格,则执行复杂表头逻辑,否则直接调用writeHeadRow(Iterable<?> rowData)
|
||||||
if (row.getLastCellNum() != 0) {
|
if (row.getLastCellNum() != 0) {
|
||||||
@@ -1111,7 +1113,7 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
|
|||||||
* @return this
|
* @return this
|
||||||
* @since 5.6.4
|
* @since 5.6.4
|
||||||
*/
|
*/
|
||||||
public ExcelWriter setColumnStyle(int x, CellStyle style){
|
public ExcelWriter setColumnStyle(int x, CellStyle style) {
|
||||||
this.sheet.setDefaultColumnStyle(x, style);
|
this.sheet.setDefaultColumnStyle(x, style);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user