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.
Unfortunately, activation email could not send to your email. Please try again.

Found a problem in ExportdataTable - here ist the corrected version

Thread ID:

Created:

Updated:

Platform:

Replies:

16649 Jul 21,2004 08:42 AM Jul 28,2004 08:17 AM Windows Forms 1
loading
Tags: XlsIO
Wolfgang Preier
Asked On July 21, 2004 08:42 AM

/// /// Exports worksheet data into a DataTable /// /// /// Row of the first cell from where DataTable should be exported /// /// /// Column of the first cell from where DataTable should be exported /// /// Maximum number of rows to export /// Maximum number of columns to export /// DataTable with worksheet data public DataTable ExportDataTable( int firstRow, int firstColumn, int maxRows, int maxColumns ) { if( firstRow < 1 || firstRow > DEF_MAX_ROW_ONE_INDEX ) throw new ArgumentOutOfRangeException( "firstRow" ); if( firstColumn < 1 || firstColumn > DEF_MAX_COLUMN_ONE_INDEX ) throw new ArgumentOutOfRangeException( "firstColumn" ); DataTable result = new DataTable( this.Name ); // Declare DataColumn and DataRow variables. DataColumn dataColumn; DataRow dataRow; maxColumns = Math.Min( maxColumns, DEF_MAX_COLUMN_ONE_INDEX - firstColumn + 1 ); maxRows = Math.Min( maxRows - 1, DEF_MAX_ROW_ONE_INDEX - firstRow + 2 ); for( int i = 0; i < maxColumns; i++ ) { dataColumn = new DataColumn(); dataColumn.DataType = System.Type.GetType( "System.String" ); dataColumn.ColumnName = Range[ firstRow, firstColumn + i ].Text; result.Columns.Add( dataColumn ); // maxRows--; } firstRow++; for( int i = 0; i < maxRows; i++ ) { dataRow = result.NewRow(); for( int j = 0; j < maxColumns; j++ ) { dataRow[ j ] = Range[ firstRow + i, firstColumn + j ].Text; } result.Rows.Add( dataRow ); } return result; }

Administrator [Syncfusion]
Replied On July 28, 2004 08:17 AM

Hi Preier, Thanks for reporting this issue. We have already fixed the problem with the ExportDataTable method and have also added an overload for exporting any given range into a DataTable. All the changes will be included in the version 2.0.6.x. Thanks. Best regards, Stephen. > /// > /// Exports worksheet data into a DataTable > /// > /// > /// Row of the first cell from where DataTable should be exported > /// > /// > /// Column of the first cell from where DataTable should be exported > /// > /// Maximum number of rows to export > /// Maximum number of columns to export > /// DataTable with worksheet data > public DataTable ExportDataTable( int firstRow, int firstColumn, int maxRows, int maxColumns ) > { > if( firstRow < 1 || firstRow > DEF_MAX_ROW_ONE_INDEX ) > throw new ArgumentOutOfRangeException( "firstRow" ); > > if( firstColumn < 1 || firstColumn > DEF_MAX_COLUMN_ONE_INDEX ) > throw new ArgumentOutOfRangeException( "firstColumn" ); > > DataTable result = new DataTable( this.Name ); > > // Declare DataColumn and DataRow variables. > DataColumn dataColumn; > DataRow dataRow; > > maxColumns = Math.Min( maxColumns, DEF_MAX_COLUMN_ONE_INDEX - firstColumn + 1 ); > maxRows = Math.Min( maxRows - 1, DEF_MAX_ROW_ONE_INDEX - firstRow + 2 ); > > for( int i = 0; i < maxColumns; i++ ) > { > dataColumn = new DataColumn(); > dataColumn.DataType = System.Type.GetType( "System.String" ); > dataColumn.ColumnName = Range[ firstRow, firstColumn + i ].Text; > result.Columns.Add( dataColumn ); > // maxRows--; > } > > firstRow++; > > for( int i = 0; i < maxRows; i++ ) > { > dataRow = result.NewRow(); > > for( int j = 0; j < maxColumns; j++ ) > { > dataRow[ j ] = Range[ firstRow + i, firstColumn + j ].Text; > } > > result.Rows.Add( dataRow ); > } > > return result; > }

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;