+ }
+
+ protected void loadAsColumns(Class<?> clss, String keyProperty,
+ Sheet sheet, Cell[] firstRow, List<Reference> references)
+ throws JXLException {
+ Cell[] firstColumn = sheet.getColumn(0);
+
+ for (int col = 1; col < firstRow.length; col++) {
+ if (log.isTraceEnabled())
+ log.trace(" column " + col);
+ BeanWrapper bw = newBeanWrapper(clss);
+ Cell[] column = sheet.getColumn(col);
+ for (int row = 0; row < column.length; row++) {
+ Cell cell = column[row];
+
+ String propertyName;
+ if (row == 0)
+ propertyName = keyProperty;
+ else
+ propertyName = firstColumn[row].getContents();
+
+ Class<?> rowType = bw.getPropertyType(propertyName);
+ if (log.isTraceEnabled())
+ log.trace(" " + propertyName + " rowType="
+ + rowType.getName());
+ if (Map.class.isAssignableFrom(rowType)) {
+ if (log.isTraceEnabled())
+ log.trace(" start building map " + propertyName);
+ row++;
+ Map<Object, Object> map = new HashMap<Object, Object>();
+ String firstColContents = firstColumn[row].getContents();
+ mapRows: for (; row < column.length; row++) {
+ cell = column[row];
+ Object key = firstColContents;
+ if (log.isTraceEnabled())
+ log.trace(" row=" + row + ", firstColContents="
+ + firstColContents + ", key=" + key
+ + ", type=" + cell.getType());
+ Object cellValue = getCellValue(cell);
+ map.put(key, cellValue);
+
+ // check next row too see if one should break
+ if (row < firstColumn.length - 1)
+ firstColContents = firstColumn[row + 1]
+ .getContents();
+ if (bw.isWritableProperty(firstColContents)
+ || firstColContents.trim().equals("")
+ || row == firstColumn.length - 1) {
+ bw.setPropertyValue(propertyName, map);
+ if (log.isTraceEnabled())
+ log.trace(" set map " + propertyName
+ + " of size " + map.size());
+ break mapRows;// map is over
+ }
+ }
+ } else {
+ loadCell(cell, bw, propertyName, keyProperty, row,
+ references);
+ }
+
+ }
+ saveOrUpdate(bw.getPropertyValue(keyProperty), bw
+ .getWrappedInstance(), clss);
+ // tempRefs.get(sheet.getName()).add(bw.getWrappedInstance());
+ registerInTabularView(sheet.getName(), bw.getWrappedInstance());
+ }// columns
+ }