I have been given a project which requires me to extract information from an excel file, do some calculations on the data and write the information back to an excel sheet. for some reason a part of my data just does feed into the cells. AN example is given below.
package ExcelDocs;
import java.io.FileOutputStream;
import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.ss.usermodel.*;
public class Trial{
public static void main(String[] agrs){
Workbook wb=new XSSFWorkbook();
Sheet ws=wb.createSheet("Testing");
Cell c1=ws.createRow(0).createCell(0);
c1.setCellValue("hello");
Cell c2=ws.createRow(1).createCell(1);
c2.setCellValue("how are you?");
for(int i=1;i<7;i++){
Cell c3=ws.createRow(i).createCell(0);
c3.setCellValue(i);
}
try{
FileOutputStream out=new FileOutputStream("ANISH.xlsx");
wb.write(out);
out.close();
} catch(Exception e){
System.out.println("unable to write to excel");
}
}
}
This code should generate the following output:
COL1 COL2
ROW1 hello
ROW2 how are you?
ROW3
ROW4
ROW5
ROW6
ROW7
instead I get this as the output
COL1 COL2
ROW1 hello
ROW2
ROW3
ROW4
ROW5
ROW6
ROW7
can anyone tell me why the "how are you?" is getting deleted? I facing the same problem in my other programs too.