Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2013-2024 Hutool Team and hutool.cn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hutool.poi.excel.sax;
import org.apache.poi.ss.usermodel.BuiltinFormats;
import org.apache.poi.xssf.model.SharedStrings;
import org.apache.poi.xssf.model.StylesTable;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.core.util.ObjUtil;
import org.dromara.hutool.poi.excel.cell.values.FormulaCellValue;
import org.dromara.hutool.poi.excel.sax.handler.RowHandler;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;
import java.util.ArrayList;
import java.util.List;
/**
* sheetData标签内容读取处理器
*
*
* <sheetData></sheetData>
*
*
* @since 5.5.3
*/
public class SheetDataSaxHandler extends DefaultHandler {
/**
* 行处理器
*/
protected RowHandler rowHandler;
// 配置项:是否对齐数据,即在行尾补充null cell
private final boolean padCellAtEndOfRow;
// 单元格的格式表,对应style.xml
protected StylesTable stylesTable;
// excel 2007 的共享字符串表,对应sharedString.xml
protected SharedStrings sharedStrings;
// sheet的索引,从0开始
protected int sheetIndex;
// 当前非空行
protected int index;
// 当前列
private int curCell;
// 单元数据类型
private CellDataType cellDataType;
// 当前行号,从0开始
private long rowNumber;
// 当前列坐标, 如A1,B5
private String curCoordinate;
// 当前节点名称
private ElementName curElementName;
// 前一个列的坐标
private String preCoordinate;
// 行的最大列坐标
private String maxCellCoordinate;
// 单元格样式
private XSSFCellStyle xssfCellStyle;
// 单元格存储的格式化字符串,nmtFmt的formatCode属性的值
private String numFmtString;
// 是否处于sheetData标签内,sax只解析此标签内的内容,其它标签忽略
private boolean isInSheetData;
// 上一次的内容
private final StringBuilder lastContent = new StringBuilder();
// 上一次的内容
private final StringBuilder lastFormula = new StringBuilder();
// 存储每行的列元素
private List