View Javadoc

1   /*
2    * 
3    * 
4    */
5   package oscon2006.web.excel;
6   
7   import java.util.*;
8   import wicket.markup.html.basic.Label;
9   import wicket.extensions.markup.html.repeater.data.GridView;
10  import wicket.extensions.markup.html.repeater.refreshing.Item;
11  import wicket.extensions.markup.html.repeater.data.table.IColumn;
12  import org.apache.poi.hssf.usermodel.*;
13  
14  public class ExcelDataTable extends 
15  	wicket.extensions.markup.html.repeater.data.table.DefaultDataTable
16  {
17  	
18  	public ExcelDataTable(String id, HSSFWorkbook wb, int sheetNum, int rowsPerPage)
19  	{
20  		super(id, buildColumnList(wb, sheetNum), new ExcelDataProvider(wb, sheetNum), rowsPerPage);
21  	}
22  	
23  	private static List buildColumnList(HSSFWorkbook wb, int sheetNum)
24  	{
25  		List columns = new ArrayList();
26  		
27  		HSSFSheet sheet = wb.getSheetAt(sheetNum);
28  		HSSFRow row = sheet.getRow(sheet.getFirstRowNum());
29  		
30  		for (int i = 0; i < row.getPhysicalNumberOfCells(); i++)
31  		{
32  			ExcelColumn c = new ExcelColumn("Column " + i);
33  			columns.add(c);
34  		}
35  		
36  		return columns;
37  	}
38  	
39  
40  	
41  }