Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i made Microsoft Excel file on java but i want to see my total column value
SUM other cell values to TOTAL column
i made 34 cells and 33 is working well with gettingValue from database but Total column do not have result (result Total = 2+33)
How to SUM this please help me

What I have tried:

XSSFRow row = sheet.createRow(0);
        XSSFCell cell = row.createCell(34);

cell = row.createCell(1);
       cell.setCellStyle(style);
       cell.setCellValue("Total");
Posted
Updated 19-Apr-18 23:07pm
v2

1 solution

You have to either create a formula cell and insert the formula to sum up the cells up to 33 (or better to current cell number minus one), or write the sum to cell 34 as value.

In the latter case you can perform the calculation in your Java code or use a database query to get it.

For the formula you have to know the Excel formula syntax and how to use that with the used POI API (XSSFCell.setCellFormula (POI API Documentation)[^]).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900