ITableIterator iterator = dataSet.iterator();
while(iterator.next())
{
// create the table i.e. sheet
ITable table = iterator.getTable();
ITableMetaData metaData = table.getTableMetaData();
HSSFSheet sheet = workbook.createSheet(metaData.getTableName());
// write table metadata i.e. first row in sheet
workbook.setSheetName(index, metaData.getTableName());
HSSFRow headerRow = sheet.createRow(0);
Column[] columns = metaData.getColumns();
for (int j = 0; j < columns.length; j++)
{
Column column = columns[j];
HSSFCell cell = headerRow.createCell(j);
cell.setCellValue(new HSSFRichTextString(column.getColumnName()));