1

I am trying to use XSSFRow to use data from one sheet to other,here is the code

XSSFRow r = nfrntSheet.getRow(i);
Cell c = r.createCell(7);
c.setCellFormula("'Original'!F"+(i+1)+"+'Original'!G"+(i+1)+"*-1");

After computing the formula the data in the written sheet will be displaced like "#value" instead of the number. what should i do to so that original data is displayed instead of the "#value"

Anand Biradar
  • 81
  • 3
  • 11

1 Answers1

1

you need to set the cell type

c.setCellType(XSSFCell.CELL_TYPE_FORMULA);

so as per your code

XSSFRow r = nfrntSheet.getRow(i);
Cell c = r.createCell(7);
 c.setCellType(XSSFCell.CELL_TYPE_FORMULA);

c.setCellFormula("'Original'!F"+(i+1)+"+'Original'!G"+(i+1)+"*-1");
SpringLearner
  • 13,738
  • 20
  • 78
  • 116