Skip to content

Commit

Permalink
hotfix: Gitee#IBI8UQ
Browse files Browse the repository at this point in the history
  • Loading branch information
getrebuild committed Jan 17, 2025
1 parent b2b55a4 commit 45d0985
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import com.alibaba.excel.write.handler.CellWriteHandler;
import com.alibaba.excel.write.handler.context.CellWriteHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
Expand All @@ -24,6 +25,7 @@
* @author Zixin
* @since 2022/12/14
*/
@Slf4j
public class FormulaCellWriteHandler implements CellWriteHandler {

private static final Pattern PATT_CELLNO = Pattern.compile("([A-Z]+[0-9]+)");
Expand All @@ -47,6 +49,11 @@ private void setCellFormula(CellWriteHandlerContext context) {
Set<String> set = new HashSet<>();
while (m.find()) {
String cellNo = m.group(1);
// v3.9.2 验证以防错误匹配 Gitee#IBI8UQ
if (!cellNo.matches("[A-Z]{1,2}[0-9]{1,3}")) {
log.warn("Bad cell no matches : {}", cellNo);
continue;
}
// 避免多次替换出错
if (set.contains(cellNo)) continue;
set.add(cellNo);
Expand Down

0 comments on commit 45d0985

Please sign in to comment.