private void writeRow(Object[] values) {
        Row row = sheet.getRow(rowIndex);
        if (row == null) {
            row = sheet.createRow(rowIndex);
        }
        rowIndex++;
        
        Cell cell = null;

        for (int cellIndex = 0; cellIndex < values.length ; cellIndex++) {
            cell = row.getCell(cellIndex);
            if (cell == null) {
                cell = row.createCell(cellIndex);
            }
            
            Object value = values[cellIndex];
            
            if (value == null) continue;
            
            if (value instanceof Date) {
                cell.setCellValue((Date) value);
            } else if (value instanceof Number) {
                cell.setCellValue(((Number) value).doubleValue());
            } else if (value instanceof Boolean) {
                cell.setCellValue((Boolean) value);
            } else {
                cell.setCellValue(value.toString());
            }
        }
    }