From: <fc...@us...> - 2007-02-05 17:22:18
|
Revision: 199 http://svn.sourceforge.net/openutils/?rev=199&view=rev Author: fcarone Date: 2007-02-05 09:22:02 -0800 (Mon, 05 Feb 2007) Log Message: ----------- Handle integer values and empty cells correctly Modified Paths: -------------- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 2007-02-05 17:20:24 UTC (rev 198) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 2007-02-05 17:22:02 UTC (rev 199) @@ -3,7 +3,6 @@ */ package it.openutils.migration.task.setup; - import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; @@ -163,30 +162,46 @@ for (short k = 0; k < columns.size() && k <= row.getLastCellNum(); k++) { HSSFCell cell = row.getCell(k); + String value = null; + if (cell == null) { - return; + value = StringUtils.EMPTY; } - - String value = null; - if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING) + else if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING) { value = cell.getStringCellValue(); } else if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) { double valueDouble = cell.getNumericCellValue(); - value = Double.toString(valueDouble); + // when need to really check if it is a double or an int + double fraction = valueDouble % 1; + if (fraction == 0) + { + value = Integer.toString((int) valueDouble); + } + else + { + value = Double.toString(valueDouble); + } } if (StringUtils.isEmpty(value)) { - return; + value = StringUtils.EMPTY; } values.add(value); } Object[] checkParams = ArrayUtils.subarray(values.toArray(), 0, checkNum); + for (int i = 0; i < checkParams.length; i++) + { + if (StringUtils.isEmpty((String) checkParams[i])) + { + return; + } + } int existing; try This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |