We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

XlsIO importing rows of zero height

Hello there,

We're using XlsIO to import Excel .xls files into our Essential Grid application, with much success, so thanks very much for some fine components.

One problem we've noticed is that rows with height of zero are reported as having the default row height (12.75 for us) by the return from:

Workbook wb = ExcelEngine.Excel.Workbooks.Open(filename);
h = wb.Worksheets[0].Rows[1].RowHeight;

Other non-default row sizes are reported accurately.

Any clues, workarounds, fixes, etc? Thanks for any assistance,

Jonathan


1 Reply

AD Administrator Syncfusion Team December 14, 2006 11:39 AM UTC

Hi Jonathan,

This can be acheived by derving the GridExcelConverterBase and create the new ExcelToGrid method to set the rowheight properly. Here is a code snippet to show this.

public class GridExcelConverterExt: Syncfusion.GridExcelConverter.GridExcelConverterBase
{
public GridExcelConverterExt():base(){}

public new void ExcelToGrid( string strFileName, GridModel grid )
{
ExcelEngine engine = CreateEngine();
IWorkbook book = engine.Excel.Workbooks.Open( strFileName );
IWorksheet sheet = book.Worksheets[ 0 ];
ExcelToGrid( sheet, grid );

grid.BeginUpdate();
CopyRowHeightToGrid(sheet,grid);
grid.EndUpdate(true);

book.Close( false );
}

private void CopyRowHeightToGrid( IWorksheet sheet, GridModel grid )
{
IRange usedRange = sheet.UsedRange;
for( int i = usedRange.Row, last = usedRange.End.Row; i <= last; i++ )
{
if( sheet.IsRowVisible(i))
grid.RowHeights[ i ] = sheet.GetRowHeightInPixels( i );
else
grid.RowHeights[ i ] = 0;
}
}
}

Please refer to attached sample for more details.
ImportExcel.zip

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon