Setting a cell value using column and row indexes throws an exception

Hi,

I have found a problem with XlsIO when trying to create a worksheet and populate it with data programmatically. 

I am using the following code, modified from an example in the documentation: https://pastebin.com/GuxL1bq1
The last line, SetValueRowCell, throws an ArgumentOutOfRangeException.

If I use:
worksheet.Range["A1"].Text = "hello";

The value is set without exception. However, I do not want to reference cells by their string coordinate, I want to use integer row/column indexes.

Is there something I am doing wrong in my example? Do I need to initialise the cells in some way before setting the value?

Thanks,
Josh


3 Replies

KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team February 14, 2020 07:32 AM UTC

Hi Josh, 

Greetings from Syncfusion. 

The value in an Excel cell can be set using SetValueRowCol method using the following code snippet. 

Code Snippet:  

//Set the value in worksheet using SetValueRowCol 
worksheet.SetValueRowCol("hello", 1, 1); 

The row and column value to be parsed in the method are one-index based.  

We have prepared a simple sample for your reference and the same can be downloaded from the following link. 

 
Please look into the following link to know more about accessing a cell or range using Syncfusion XlsIO. 
 

Kindly try the sample and let us know if your requirement is fulfilled. 

Regards, 
Keerthi.


JO Josh February 16, 2020 08:55 PM UTC

Hi Keerthi, that works great for us. Thank you for your reply!


KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team February 17, 2020 06:16 AM UTC

Hi Josh, 

Thanks for your update. 

We are glad that the provided suggestion helped you. Kindly let us know if you need any further assistance. 

Regards, 
Keerthi.

Loader.
Up arrow icon