public static QueryResult convert(ResultSet rs, int limit) throws Exception {
Integer width = 0;
Integer height = 0;
ResultSetHelper rsch = new ResultSetHelper();
Cell[] header = null;
ArrayList<Cell[]> rows = new ArrayList<Cell[]>();
// System.out.println("DATASET");
try {
while (rs.next() && (limit == 0 || height < limit)) {
if (height == 0) {
width = rs.getMetaData().getColumnCount();
header = new Cell[width];
for (int s = 0; s < width; s++) {
header[s] = new Cell(rs.getMetaData().getColumnName(s + 1), Cell.Type.COLUMN_HEADER);
}
if (width > 0) {
rows.add(header);
// System.out.println(" |");
}
}
Cell[] row = new Cell[width];
for (int i = 0; i < width; i++) {
int colType = rs.getMetaData().getColumnType(i + 1);
String content = rsch.getValue(rs, colType, i + 1);
if (content == null) {
content = "";
}
row[i] = new Cell(content, Cell.Type.DATA_CELL);
}