[英]How to get value from the merged excel cell?
需要幫助以從“標價總計”獲取合並的單元格值。 如上圖所示,其合並后的單元格從第13行到第18行開始。 我正在使用下面的代碼來獲取值,但仍將其獲取為null。
CellRangeAddress mergedCell = new CellRangeAddress(12, 17, 9, 9);
int rowNum = mergedCell.getFirstRow();
int lastRow = mergedCell.getLastRow();
int colIndex = mergedCell.getFirstColumn();
for (int rowCounter = rowNum; rowCounter < lastRow; rowCounter++) {
Cell cell2Update = sheet.getRow(rowCounter).getCell(colIndex);
cell2Update.setCellType(Cell.CELL_TYPE_NUMERIC);
CellValue c = evaluator.evaluate(cell2Update);
if (null != c) {
Double lisPrice= c.getNumberValue();
if (lisPrice> 0) {
spreadheetResultData.setListPricetotal(df.format(lisPrice));
}
}
}
請幫助我以獲得合並的單元格值。
如評論中所述,僅指最左上角的單元格,例如,如果合並范圍A2到C4,則= A2的公式將返回合並的單元格的內容,這與宏相同。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.