作者:乔山办公网日期:
返回目录:excel表格制作
poi的api文档如下知
https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/Sheet.html
希望对道你有用,经回过查找核对后,还答是用getColumnWidth
cell.getRowIndex();// 行号从0开始计数
cell.getColumnIndex();// 列号从0开始计数
/**
* 获取合并单元格的值
* @7a686964616fe4b893e5b19e339param sheet
* @param row
* @param column
* @return
*/
public String getMergedRegionValue(Sheet sheet, int row, int column) {
int sheetMergeCount = sheet.getNumMergedRegions();
for (int i = 0; i < sheetMergeCount; i++) {
CellRangeAddress ca = sheet.getMergedRegion(i);
int firstColumn = ca.getFirstColumn();
int lastColumn = ca.getLastColumn();
int firstRow = ca.getFirstRow();
int lastRow = ca.getLastRow();
if (row >= firstRow && row <= lastRow) {
if (column >= firstColumn && column <= lastColumn) {
Row fRow = sheet.getRow(firstRow);
Cell fCell = fRow.getCell(firstColumn);
return getCellValue(fCell);
}
}
}
return null;
}
首先判断是不是公式百,如果是设置其单度元格类型为数问字,然后获取值就可以得到答
case HSSFCell.CELL_TYPE_FORMULA: //首先判断一下是不是公版式
cell.setCellType(Cell.CELL_TYPE_NUMERIC); //设置其单元格类型为数字
result = cell.getNumericCellValue(); //获取数字值权
break;