|111033||Sep 4,2013 07:07 PM UTC||Sep 6,2013 12:16 PM UTC||WinForms||1|
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?
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;
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.
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.
This page will automatically be redirected to the sign-in page in 10 seconds.