mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix poi
This commit is contained in:
parent
ef235aab5d
commit
a444d00e98
@ -23,6 +23,7 @@
|
|||||||
* 【core 】 BooleanConverter增加数字转换规则(issue#I1R2AB@Gitee)
|
* 【core 】 BooleanConverter增加数字转换规则(issue#I1R2AB@Gitee)
|
||||||
* 【poi 】 sax方式读取增加一个sheet结束的回调(issue#155@Gitee)
|
* 【poi 】 sax方式读取增加一个sheet结束的回调(issue#155@Gitee)
|
||||||
* 【db 】 增加BeeCP连接池支持
|
* 【db 】 增加BeeCP连接池支持
|
||||||
|
* 【core 】 改进Img.pressImage方法,避免变色问题(issue#1001@Github)
|
||||||
|
|
||||||
### Bug修复#
|
### Bug修复#
|
||||||
* 【core 】 修复原始类型转换时,转换失败没有抛出异常的问题
|
* 【core 】 修复原始类型转换时,转换失败没有抛出异常的问题
|
||||||
|
@ -507,7 +507,7 @@ public class Img implements Serializable {
|
|||||||
public Img pressImage(Image pressImg, Rectangle rectangle, float alpha) {
|
public Img pressImage(Image pressImg, Rectangle rectangle, float alpha) {
|
||||||
final Image targetImg = getValidSrcImg();
|
final Image targetImg = getValidSrcImg();
|
||||||
|
|
||||||
this.targetImage = draw(ImgUtil.toBufferedImage(targetImg), pressImg, rectangle, alpha);
|
this.targetImage = draw(ImgUtil.toBufferedImage(targetImg, this.targetImageType), pressImg, rectangle, alpha);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,11 @@ public class BeeDSFactory extends AbstractDSFactory {
|
|||||||
final BeeDataSourceConfig beeConfig = new BeeDataSourceConfig(driver, jdbcUrl, user, pass);
|
final BeeDataSourceConfig beeConfig = new BeeDataSourceConfig(driver, jdbcUrl, user, pass);
|
||||||
poolSetting.toBean(beeConfig);
|
poolSetting.toBean(beeConfig);
|
||||||
|
|
||||||
|
// 修复BeeCP默认参数无效问题
|
||||||
|
if(beeConfig.getBorrowConcurrentSize() > beeConfig.getMaxActive()){
|
||||||
|
beeConfig.setMaxActive(beeConfig.getBorrowConcurrentSize() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
// remarks等特殊配置,since 5.3.8
|
// remarks等特殊配置,since 5.3.8
|
||||||
String connValue;
|
String connValue;
|
||||||
for (String key : KEY_CONN_PROPS) {
|
for (String key : KEY_CONN_PROPS) {
|
||||||
|
@ -2,6 +2,7 @@ package cn.hutool.db;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.db.ds.DSFactory;
|
import cn.hutool.db.ds.DSFactory;
|
||||||
|
import cn.hutool.db.ds.bee.BeeDSFactory;
|
||||||
import cn.hutool.db.ds.c3p0.C3p0DSFactory;
|
import cn.hutool.db.ds.c3p0.C3p0DSFactory;
|
||||||
import cn.hutool.db.ds.dbcp.DbcpDSFactory;
|
import cn.hutool.db.ds.dbcp.DbcpDSFactory;
|
||||||
import cn.hutool.db.ds.druid.DruidDSFactory;
|
import cn.hutool.db.ds.druid.DruidDSFactory;
|
||||||
@ -59,6 +60,15 @@ public class DsTest {
|
|||||||
Assert.assertTrue(CollUtil.isNotEmpty(all));
|
Assert.assertTrue(CollUtil.isNotEmpty(all));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void beeCPDsTest() throws SQLException {
|
||||||
|
DSFactory.setCurrentDSFactory(new BeeDSFactory());
|
||||||
|
DataSource ds = DSFactory.get("test");
|
||||||
|
Db db = Db.use(ds);
|
||||||
|
List<Entity> all = db.findAll("user");
|
||||||
|
Assert.assertTrue(CollUtil.isNotEmpty(all));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void dbcpDsTest() throws SQLException {
|
public void dbcpDsTest() throws SQLException {
|
||||||
DSFactory.setCurrentDSFactory(new DbcpDSFactory());
|
DSFactory.setCurrentDSFactory(new DbcpDSFactory());
|
||||||
|
@ -511,12 +511,12 @@ public class ExcelReader extends ExcelBase<ExcelReader> {
|
|||||||
* @return 转换别名列表
|
* @return 转换别名列表
|
||||||
*/
|
*/
|
||||||
private List<String> aliasHeader(List<Object> headerList) {
|
private List<String> aliasHeader(List<Object> headerList) {
|
||||||
final int size = headerList.size();
|
if(CollUtil.isEmpty(headerList)){
|
||||||
final ArrayList<String> result = new ArrayList<>(size);
|
return new ArrayList<>(0);
|
||||||
if (CollUtil.isEmpty(headerList)) {
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final int size = headerList.size();
|
||||||
|
final ArrayList<String> result = new ArrayList<>(size);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
result.add(aliasHeader(headerList.get(i), i));
|
result.add(aliasHeader(headerList.get(i), i));
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
package cn.hutool.poi.excel;
|
package cn.hutool.poi.excel;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import java.util.List;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.poi.excel.cell.CellEditor;
|
||||||
|
import cn.hutool.poi.excel.cell.CellUtil;
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import java.util.ArrayList;
|
||||||
import cn.hutool.poi.excel.cell.CellEditor;
|
import java.util.List;
|
||||||
import cn.hutool.poi.excel.cell.CellUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Excel中的行{@link Row}封装工具类
|
* Excel中的行{@link Row}封装工具类
|
||||||
*
|
*
|
||||||
* @author looly
|
* @author looly
|
||||||
* @since 4.0.7
|
* @since 4.0.7
|
||||||
*/
|
*/
|
||||||
public class RowUtil {
|
public class RowUtil {
|
||||||
/**
|
/**
|
||||||
* 获取已有行或创建新行
|
* 获取已有行或创建新行
|
||||||
*
|
*
|
||||||
* @param sheet Excel表
|
* @param sheet Excel表
|
||||||
* @param rowIndex 行号
|
* @param rowIndex 行号
|
||||||
* @return {@link Row}
|
* @return {@link Row}
|
||||||
* @since 4.0.2
|
* @since 4.0.2
|
||||||
@ -36,23 +36,38 @@ public class RowUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 读取一行
|
* 读取一行
|
||||||
*
|
*
|
||||||
* @param row 行
|
* @param row 行
|
||||||
* @param cellEditor 单元格编辑器
|
* @param cellEditor 单元格编辑器
|
||||||
* @return 单元格值列表
|
* @return 单元格值列表
|
||||||
*/
|
*/
|
||||||
public static List<Object> readRow(Row row, CellEditor cellEditor) {
|
public static List<Object> readRow(Row row, CellEditor cellEditor) {
|
||||||
|
return readRow(row, 0, Short.MAX_VALUE, cellEditor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取一行
|
||||||
|
*
|
||||||
|
* @param row 行
|
||||||
|
* @param startCellNumInclude 起始单元格号,0开始(包含)
|
||||||
|
* @param endCellNumInclude 结束单元格号,0开始(包含)
|
||||||
|
* @param cellEditor 单元格编辑器
|
||||||
|
* @return 单元格值列表
|
||||||
|
*/
|
||||||
|
public static List<Object> readRow(Row row, int startCellNumInclude, int endCellNumInclude, CellEditor cellEditor) {
|
||||||
if (null == row) {
|
if (null == row) {
|
||||||
return new ArrayList<>(0);
|
return new ArrayList<>(0);
|
||||||
}
|
}
|
||||||
final short length = row.getLastCellNum();
|
final short rowLength = row.getLastCellNum();
|
||||||
if (length < 0) {
|
if (rowLength < 0) {
|
||||||
return new ArrayList<>(0);
|
return ListUtil.empty();
|
||||||
}
|
}
|
||||||
final List<Object> cellValues = new ArrayList<>(length);
|
|
||||||
|
final int size = Math.min(endCellNumInclude + 1, rowLength);
|
||||||
|
final List<Object> cellValues = new ArrayList<>(size);
|
||||||
Object cellValue;
|
Object cellValue;
|
||||||
boolean isAllNull = true;
|
boolean isAllNull = true;
|
||||||
for (short i = 0; i < length; i++) {
|
for (int i = startCellNumInclude; i < size; i++) {
|
||||||
cellValue = CellUtil.getCellValue(row.getCell(i), cellEditor);
|
cellValue = CellUtil.getCellValue(row.getCell(i), cellEditor);
|
||||||
isAllNull &= StrUtil.isEmptyIfStr(cellValue);
|
isAllNull &= StrUtil.isEmptyIfStr(cellValue);
|
||||||
cellValues.add(cellValue);
|
cellValues.add(cellValue);
|
||||||
@ -60,16 +75,16 @@ public class RowUtil {
|
|||||||
|
|
||||||
if (isAllNull) {
|
if (isAllNull) {
|
||||||
// 如果每个元素都为空,则定义为空行
|
// 如果每个元素都为空,则定义为空行
|
||||||
return new ArrayList<>(0);
|
return ListUtil.empty();
|
||||||
}
|
}
|
||||||
return cellValues;
|
return cellValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 写一行数据
|
* 写一行数据
|
||||||
*
|
*
|
||||||
* @param row 行
|
* @param row 行
|
||||||
* @param rowData 一行的数据
|
* @param rowData 一行的数据
|
||||||
* @param styleSet 单元格样式集,包括日期等样式
|
* @param styleSet 单元格样式集,包括日期等样式
|
||||||
* @param isHeader 是否为标题行
|
* @param isHeader 是否为标题行
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user