xlsx4j - How to set column width in spreadsheet?
===

I'm trying to export JTable to XLSX file using xlsx4j, but have trouble with setting the columns widths.
I've succeeded in setting the default width for all the columns, but I would like to set the widths of columns to fit data lenght automatically:



	public void exportToXLS() throws Exception
	{			
		//Create the spreadsheet
		SpreadsheetMLPackage pkg = SpreadsheetMLPackage.createPackage();
		WorksheetPart sheet = pkg.createWorksheetPart(new PartName("/xl/worksheets/sheet1.xml"), "Sheet1", 1);
		
		//Set default format for rows and columns
		CTSheetFormatPr format = Context.getsmlObjectFactory().createCTSheetFormatPr();
		format.setDefaultColWidth(20.0);		
		format.setDefaultRowHeight(16.8);
		format.setCustomHeight(Boolean.TRUE);
		sheet.getJaxbElement().setSheetFormatPr(format);

		//Get a few JTable properties 
		int iSelectedTab = tabPane.getSelectedIndex();
		int[] rowsSelected = table[iSelectedTab].getSelectedRows();
		int iColumns = table[0].getColumnCount();
		int iCurrentRow;
		
		//Retrieve SheetData from sheet object
		SheetData sheetData = sheet.getJaxbElement().getSheetData();
		Row row;
		Cell cell;

		//Copy data from JTable to spreadsheet	
		for(int iRow=0; iRow < rowsSelected.length; iRow++)
		{						
			iCurrentRow = rowsSelected[iRow];
			row = Context.getsmlObjectFactory().createRow();
			List<Cell>rowl = row.getC();
			for(int iCol = 0; iCol < iColumns; iCol++)
			{
				cell = Context.getsmlObjectFactory().createCell();				
				CTRst ctrst = new CTRst();
				ctrst.setT(table[iSelectedTab].getValueAt(iCurrentRow, iCol).toString());
				cell.setT(STCellType.INLINE_STR);
				cell.setIs(ctrst);	            
				rowl.add(cell);
				
			}
			sheetData.getRow().add(row);			
		}

		//Set the columns widths
		List<Cols> lstCols = sheet.getJaxbElement().getCols();
		System.out.println("lstCols.size() is " + lstCols.size());
		for(int i = 0; i< lstCols.size(); i++)
		{
			List<Col> lstCol = lstCols.get(i).getCol();
			System.out.println("lstCol.size() is " + lstCol.size());
			for(int j=0; j<lstCol.size(); j++)
			{				
				lstCol.get(j).setBestFit(Boolean.TRUE);
				lstCol.get(j).setWidth(30.0);	
				System.out.println("Column " + i + " : " + j);
			}
		}

		//Save the spreadsheet to file
		pkg.save(new File("Export.xlsx"));				
	}

The above code shows in console:
	lstCols.size() is 0
so it looks like after adding rows and cells to the SheetData, there are no columns definitions.       

On the other hand if I create the columns manually this way: 

	Cols cols = Context.smlObjectFactory.createCols();	
	Col col = Context.smlObjectFactory.createCol();
	col.setBestFit(Boolean.TRUE);
	cols.getCol().add(col);
	sheet.getJaxbElement().getCols().add(cols);

I get the catastrophic error in XLSX file.
