Sheet sheet = workbook.getSheet(0);
if (columnNames.size() == 0)
{
for(int columnIndex = 0; columnIndex < sheet.getColumns(); columnIndex++)
{
Cell cell = sheet.getCell(columnIndex, recordIndex);
String columnName = cell.getContents();
if (columnName != null && columnName.trim().length() > 0)
{
columnNames.put(columnName, Integer.valueOf(columnIndex));
}
}
}
else
{
Map newColumnNames = new HashMap();
for(Iterator it = columnNames.values().iterator(); it.hasNext();)
{
Integer columnIndex = (Integer)it.next();
Cell cell = sheet.getCell(columnIndex.intValue(), recordIndex);
String columnName = cell.getContents();
newColumnNames.put(columnName, columnIndex);
}
columnNames = newColumnNames;
}