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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Comparable functions/process for IRange to interop Range?

Thread ID:

Created:

Updated:

Platform:

Replies:

111033 Sep 4,2013 07:07 PM UTC Sep 6,2013 12:16 PM UTC WinForms 1
loading
Tags: XlsIO
Eric Strehl
Asked On September 4, 2013 07:07 PM UTC

Trying to refactor a com interop console app to use Syncfusion XlsIO. The application is doing a cell-by-cell comparison of values in two different worksheets. The former process was to get the usedRange.Value2 as an object[,] for each sheet, then loop through the arrays.  For XlsIO, though, the Value2, Value, and Text properties on the used range are all null. Is this by design? Is there another means to create a 2D container (so easy to log location of non-matching data) with the values from cells in a worksheet?

 

TIA


Sridhar [Syncfusion]
Replied On September 6, 2013 12:16 PM UTC

Hi Eric Strehl,

Thank you for using Syncfusion products.

We do not have any custom method to export the Excel sheet data to an 2D array. So we have created an workaround to loop through the rows and column of an sheet data and export into an 2D array.

Please make use of the below code for the same.

Code Snippet [C#]:

IWorksheet worksheet = workbook.Worksheets[0];
IRange range = worksheet.UsedRange;

int lastRow = range.LastRow;
int lastColumn = range.LastColumn;

// Instantiate a new two-dimensional string array.
string[,] dataArray = new string[lastRow, lastColumn];

for (int i = 1; i <= lastRow; i++)
{
  for (int j = 1; j <= lastColumn; j++)
  {
    //Exporting the data to an 2D array     
     dataArray[i - 1, j - 1] = worksheet.Range[i, j].DisplayText;
   }
}

Please try the above code snippet and let us know if these helps you.

As mentioned in your last post, if you are still facing an issue with Value,Value2 and Text properties are null for the used range is null then could you please get back to us with the simple sample (The excel file and the source code used to read excel cells) which reproduces this issue so that we are able to proceed further on this..

Please let us know if need any further assistance.

Thanks,
Sridhar.S


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.

Warning Icon 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.Close Icon

;