mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
1879292a11
commit
01e81de806
@ -318,11 +318,7 @@ public class ExcelBase<T extends ExcelBase<T, C>, C extends ExcelConfig> impleme
|
|||||||
* @since 4.0.6
|
* @since 4.0.6
|
||||||
*/
|
*/
|
||||||
public Cell getCell(final int x, final int y, final boolean isCreateIfNotExist) {
|
public Cell getCell(final int x, final int y, final boolean isCreateIfNotExist) {
|
||||||
final Row row = isCreateIfNotExist ? RowUtil.getOrCreateRow(this.sheet, y) : this.sheet.getRow(y);
|
return CellUtil.getCell(this.sheet, x, y, isCreateIfNotExist);
|
||||||
if (null != row) {
|
|
||||||
return isCreateIfNotExist ? CellUtil.getOrCreateCell(row, x) : row.getCell(x);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import org.apache.poi.ss.util.CellReference;
|
|||||||
import org.apache.poi.ss.util.RegionUtil;
|
import org.apache.poi.ss.util.RegionUtil;
|
||||||
import org.apache.poi.ss.util.SheetUtil;
|
import org.apache.poi.ss.util.SheetUtil;
|
||||||
import org.dromara.hutool.core.util.ObjUtil;
|
import org.dromara.hutool.core.util.ObjUtil;
|
||||||
|
import org.dromara.hutool.poi.excel.RowUtil;
|
||||||
import org.dromara.hutool.poi.excel.cell.editors.CellEditor;
|
import org.dromara.hutool.poi.excel.cell.editors.CellEditor;
|
||||||
import org.dromara.hutool.poi.excel.cell.editors.TrimEditor;
|
import org.dromara.hutool.poi.excel.cell.editors.TrimEditor;
|
||||||
import org.dromara.hutool.poi.excel.cell.setters.CellSetter;
|
import org.dromara.hutool.poi.excel.cell.setters.CellSetter;
|
||||||
@ -190,6 +191,24 @@ public class CellUtil {
|
|||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
// region ----- getCell
|
// region ----- getCell
|
||||||
|
/**
|
||||||
|
* 获取指定坐标单元格,如果isCreateIfNotExist为false,则在单元格不存在时返回{@code null}
|
||||||
|
*
|
||||||
|
* @param sheet {@link Sheet}
|
||||||
|
* @param x X坐标,从0计数,即列号
|
||||||
|
* @param y Y坐标,从0计数,即行号
|
||||||
|
* @param isCreateIfNotExist 单元格不存在时是否创建
|
||||||
|
* @return {@link Cell}
|
||||||
|
* @since 6.0.0
|
||||||
|
*/
|
||||||
|
public static Cell getCell(final Sheet sheet, final int x, final int y, final boolean isCreateIfNotExist) {
|
||||||
|
final Row row = isCreateIfNotExist ? RowUtil.getOrCreateRow(sheet, y) : sheet.getRow(y);
|
||||||
|
if (null != row) {
|
||||||
|
return isCreateIfNotExist ? getOrCreateCell(row, x) : row.getCell(x);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取单元格,如果单元格不存在,返回{@link NullCell}
|
* 获取单元格,如果单元格不存在,返回{@link NullCell}
|
||||||
*
|
*
|
||||||
|
@ -1011,6 +1011,17 @@ public class ExcelWriter extends ExcelBase<ExcelWriter, ExcelWriteConfig> {
|
|||||||
// region ----- fill
|
// region ----- fill
|
||||||
|
|
||||||
public ExcelWriter fillRow(final Map<?, ?> rowMap){
|
public ExcelWriter fillRow(final Map<?, ?> rowMap){
|
||||||
|
rowMap.forEach((key, value)->{
|
||||||
|
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExcelWriter fillCell(final String name, final Object value){
|
||||||
|
final Cell cell = this.templateContext.getCell(name);
|
||||||
|
if(null != cell){
|
||||||
|
CellUtil.setCellValue(cell, value, this.config.getCellEditor());
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user