Note that there are some explanatory texts on larger screens.

plurals
  1. POset Excel cell values of all type using Java
    primarykey
    data
    text
    <p>I have a requirement to copy Excel row from one sheet to another. But after copying instead of actual values, I am getting different values. There is no problem with cells having string values, but with numeric values. Excel cell can contain any type of value. My code should accept all of them and copy the same in another sheet. Please help me in this case.</p> <pre><code>if(row.getCell(getLastCell)!=null &amp;&amp; ((row.getCell(getLastCell).toString().equalsIgnoreCase(FAIL))|| (row.getCell(getLastCell).toString().equalsIgnoreCase("Invalid CR Statement")))) { failuresRow=failuresSheet.createRow(createNewRow++); for(int ii=0;ii&lt;=getLastCell;ii++) { failuresCell=failuresRow.createCell(ii); failuresCell.setCellValue(row.getCell(ii)+""); failuresCell.setCellType(row.getCell(ii).getCellType()); failuresCell.setCellStyle(row.getCell(ii).getCellStyle()); } } </code></pre> <p>I know that row.getCell(ii)+"" is to convert type Cell to string, but I want to set setCellValue to accept cell which can have any type of data(eg: Date, Bollean, String, Number, .........) </p> <p>I have tried using DataFormatter and in some other way also as below, but no use.</p> <pre><code> failuresCell.setCellValue(df.formatCellValue(row.getCell(ii))); switch (cell.getCellType()) { case Cell.CELL_TYPE_STRING: failuresCell.setCellValue(cell.getRichStringCellValue().getString()); break; case Cell.CELL_TYPE_NUMERIC: if (DateUtil.isCellDateFormatted(cell)) { failuresCell.setCellValue(cell.getDateCellValue()); } else { failuresCell.setCellValue(cell.getNumericCellValue()); } break; case Cell.CELL_TYPE_BOOLEAN: failuresCell.setCellValue(cell.getBooleanCellValue()); break; case Cell.CELL_TYPE_FORMULA: failuresCell.setCellValuec(cell.getCellFormula()); break; default: // some code } </code></pre> <p>If cell have the numeric value 9200278, getting output as 1717. I don't understand where I am doing wrong. Please help me in this case.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload