开发者

How can get the sum of different cell values in excel using POI

开发者 https://www.devze.com 2022-12-13 10:00 出处:网络
i got requirement like,i created Excel sheet using POI.In that excel i have row one and row two,each开发者_如何学JAVA row containg three cells with different value,like row two contains same.

i got requirement like,i created Excel sheet using POI.In that excel i have row one and row two,each开发者_如何学JAVA row containg three cells with different value,like row two contains same.

how can i add the r0c0+r1c0+r2c0 value into a anothe cell.

is there any API for that.

if any come across the solution please help me.


With POI, you can use formulas in cells exactly like you would type then in Excel:

Row row4 = sheet.createRow(4);
Cell cell = row.createCell(1);

String cellsFrom_A1_to_A3 = "A1:A3";
cell.setCellFormula("SUM("+cellsFrom_A1_to_A3+")");

Cell cell2 = row.createCell(2);
cell2.setCellFormula("A1+A2");
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号