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
close icon

Getting value from sheet is too slow

    Hi,
I'm using XlsIO in SL.
We want to getting values from each cell in sheet.
The code is like below.
 
--code here--
foreach (IWorksheet sheet in workbook.Worksheets)
                    {
                        for (int row = 1; row <= sheet.Rows.Length; row++)
                        {                           
                            for (int column = 1; column <= sheet.Columns.Length; column++)
                            {
                                object cell = sheet.GetValueRowCol(row, column);
                                //Do something w/ cell
                            }
                        }
                    }     
 
Surely, I tested the performance except for any other logic.
The excel file is amount of 25000(row)*30(column), ti takes about 20 minutes.
Is there faster way of reading each cell?
 
Thank you.
 
 
 

3 Replies

MM Manikandan M Syncfusion Team June 27, 2012 08:40 AM UTC

Hi Jiwon,

 

Thanks for using Syncfusion products.

 

On analysis we found that XlsIO takes 20 min (nearly) to read the cell of the sheet which contains values in 25000 rows and 30 columns as ’sheet.Rows.Length’, 'sheet.Columns.Length' properties are called on each loop execution. So please as workaround, assign the 'sheet.Rows.Length' and 'sheet.Column.Length' to local variable and use that local variable in for loop. When using this workaround, we could see that XlsIO takes 3 seconds to read the cell values.

 

Code snippet:

foreach (IWorksheet sheet in workbook.Worksheets)

            {

                int rowLength = sheet.Rows.Length;

                int columnLength = sheet.Columns.Length;

                for (int row = 1; row <= rowLength; row++)

                {

                    for (int column = 1; column <= columnLength ; column++)

                    {

                        object cell = sheet.GetValueRowCol(row, column);

                        //Do something

                    }

                }

            }

We have attached the simplified sample with the above scenario. Please make use of this and let us know whether this helps you.

 

Thanks,

Manikandan.M

 



Performance_2185a604.zip


JI Jiwon June 27, 2012 11:53 AM UTC

I also found it takes just 3 seconds.
I can't believe that I couldn't try that. 
Thank you.
 
 
  


MM Manikandan M Syncfusion Team June 29, 2012 07:30 AM UTC

Hi Jiwon,

 

Thanks for your update.

 

We are happy to hear that reported issue has been resolved. Please let us know if you need any assistance on this.

 

Thanks,

Manikandan.M


Loader.
Live Chat Icon For mobile
Up arrow icon