public class PoiUtils {
/**
* 根据行内容重新计算行高
* @param row
*/
public static void calcAndSetRowHeigt(HSSFRow sourceRow) {
for (int cellIndex = sourceRow.getFirstCellNum(); cellIndex <= sourceRow.getPhysicalNumberOfCells(); cellIndex++) {
//行高
double maxHeight = sourceRow.getHeight();
HSSFCell sourceCell = sourceRow.getCell(cellIndex);
//单元格的内容
String cellContent = getCellContentAsString(sourceCell);
if(null == cellContent || “”.equals(cellContent)){
continue;
}
//单元格的宽高及单元格信息
Map<String, Object> cellInfoMap = getCellInfo(sourceCell);
Integer cellWidth = (Integer)cellInfoMap.get(“width”);
Integer cellHeight = (Integer)cellInfoMap.get(“height”);
if(cellHeight > maxHeight){
maxHeight = cellHeight;
}
HSSFCellStyle cellStyle = sourceCell.getCellStyle();
poi 获取自动换行后行高
最新推荐文章于 2022-11-08 10:18:07 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)