Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JSpreadsheet
>
Tutorial
> Sum Cells
The following example shows you how to add formula to a cell.
import com.independentsoft.office.spreadsheet.Cell; import com.independentsoft.office.spreadsheet.Formula; import com.independentsoft.office.spreadsheet.Workbook; import com.independentsoft.office.spreadsheet.Worksheet; public class Example { public static void main(String[] args) { try { Cell a1 = new Cell(100); Cell b1 = new Cell(200); Cell c1 = new Cell(); Formula formula = new Formula("SUM(A1,B1)"); c1.setFormula(formula); Worksheet sheet1 = new Worksheet(); sheet1.set("A1", a1); sheet1.set("B1", b1); sheet1.set("C1", c1); Workbook book = new Workbook(); book.getSheets().add(sheet1); book.save("c:\\test\\output.xlsx", true); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } }
Need help? Ask our developers:
Name*
Email*
Message*