I am reading an excel which has some cells as double type. I want to read and print them as strings.
My sample excel file has following data.
Date|City|Credit|Debit|Balance|Type 10-01-2019|New Delhi|1000000.00||1000000.00|CR 10-01-2019|Mumbai|50000000.00|40000000.00|10000000.00|CR 10-01-2019|Chennai||200000.00|200000.00|DR 10-01-2019|Kolkatta||10000.00|10000.00|DR 10-01-2019|Srinagar|100000000.00|40000000.00|60000000.00|CR
I want to print double amount as strings.
I have tried following code:
public static void main(String[] args) throws FileNotFoundException{
FileInputStream CA = new FileInputStream(new File("C:/Java projects/RBI/RBI.xlsx"));
public static void main(String[] args) throws FileNotFoundException{
FileInputStream CA = new FileInputStream(new File("C:/Java projects/RBI/RBI.xlsx"));
try
{
XSSFWorkbook CAworkbook = new XSSFWorkbook(CA);
XSSFSheet sheet = CAworkbook.getSheetAt(0);
Iterator<Row> rowIterator = sheet.iterator();
ArrayList<String> CA1 = new ArrayList<String>();
while (rowIterator.hasNext())
{
Row row = rowIterator.next();
Iterator<Cell> cellIterator = row.cellIterator();
CA1.add( row.getCell(1) + "|" +row.getCell(2)+ "|" +row.getCell(3)+ "|" + row.getCell(4)+ "|" +row.getCell(5)+ "|" + row.getCell(6));
System.out.println( row.getCell(1) + "|" +row.getCell(2)+ "|" +row.getCell(3)+ "|" + row.getCell(4)+ "|" +row.getCell(5)+ "|" + row.getCell(6));
}
}
catch (IOException e) {
e.printStackTrace();
}
}
Output is as under:-
10-01-2019|New Delhi|1000000.0||1000000.0|CR 10-01-2019|Mumbai|5.0E7|4.0E7|1.0E7|CR 10-01-2019|Chennai||200000.0|200000.0|DR 10-01-2019|Kolkatta||10000.0|10000.0|DR 10-01-2019|Srinagar|1.0E8|4.0E7|6.0E7|CR