HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet( "Export" ); //$NON-NLS-1$
// header
HSSFRow headerRow = sheet.createRow( 0 );
LinkedHashMap<String, Short> attributeNameMap = new LinkedHashMap<String, Short>();
if ( this.exportDn )
{
short cellNum = ( short ) 0;
attributeNameMap.put( "dn", new Short( cellNum ) ); //$NON-NLS-1$
headerRow.createCell( cellNum ).setCellValue( "dn" ); //$NON-NLS-1$
}
// String[] exportAttributes =
// this.searchParameter.getReturningAttributes();
// exportAttributes = null;
// for (int i = 0; exportAttributes != null && i <
// exportAttributes.length; i++) {
// short cellNum = (short)attributeNameMap.size();
// attributeNameMap.put(exportAttributes[i], new Short(cellNum));
// headerRow.createCell(cellNum).setCellValue(exportAttributes[i]);
// }
// max export
if ( searchParameter.getCountLimit() < 1 || searchParameter.getCountLimit() > MAX_COUNT_LIMIT )
{
searchParameter.setCountLimit( MAX_COUNT_LIMIT );
}
// export
try
{
int count = 0;
exportToXls( browserConnection, searchParameter, sheet, headerRow, count, monitor, attributeNameMap,
valueDelimiter, binaryEncoding, this.exportDn );
}
catch ( Exception e )
{
monitor.reportError( e );
}
// column width
for ( int i = 0; i <= sheet.getLastRowNum(); i++ )
{
HSSFRow row = sheet.getRow( i );
for ( short j = 0; row != null && j <= row.getLastCellNum(); j++ )
{
HSSFCell cell = row.getCell( j );
if ( cell != null && cell.getCellType() == HSSFCell.CELL_TYPE_STRING )
{
String value = cell.getStringCellValue();
if ( ( short ) ( value.length() * 256 * 1.1 ) > sheet.getColumnWidth( j ) )