Getting Cell data returns value type instead of value

0 Answers 14 Views
SpreadProcessing
Steven
Top achievements
Rank 1
Iron
Steven asked on 26 Apr 2022, 07:48 PM

I am starting with the Telerik Document processing libraries.  I have a simple excel file that I would like to import into a list to work with in my program.  

I have an imported workbook and worksheet that seems to work.  When I try to get the data from a test cell however:


string test;
test = sheet.Cells[0,0].GetValue().ToString();

instead of returning the value I put in the cell I get:

"Telerik.Windows.Documents.Spreadsheet.Model.RangePropertyValue`1[Telerik.Windows.Documents.Spreadsheet.Model.ICellValue]"

 

I have been reading the documentation and can't figure out what I am doing wrong.  

 

(for the record:

test = sheet.Cells[0,0].GetValue().Value.ToString(); returns 

"Telerik.Windows.Documents.Spreadsheet.Model.NumberCellValue"

so it isn't helpful either.)

 

Steven
Top achievements
Rank 1
Iron
commented on 26 Apr 2022, 10:16 PM

I figured out a method of getting the data that I need:

test = sheet.Cells.GetCellSelection(0,0).GetValue().Value.RawValue.ToString() ??"";
This returns the correct result but seems overly complicated.  Is there a better way?
Svilen
Telerik team
commented on 27 Apr 2022, 09:08 AM

Hey, Steven,

I'd be glad to help out here.

The method you've used is the fastest way to get a cell's value. I agree that, at first look, it seems more complicated than one might expect, compared to getting a cell value in Excel. This is due to how a spreadsheet's cells' values are maintained "under the hood". Without getting into excess detail, our API maintains high performance and allows for granular control over a spreadsheet's elements, but at times adds a bit more complexity when it comes to simpler tasks, such as this one.

I recommend checking this post in our forum, which lists two more ways of getting cell values - Just get the value of a cell. It goes into some useful detail regarding formulas, cell value types, and cell formats. I believe it proves most useful when starting out with RadSpreadProcessing. Please do reach out again should you have any other questions. I remain at your disposal.

Regards,
Svilen
Progress Telerik

No answers yet. Maybe you can help?

Tags
SpreadProcessing
Asked by
Steven
Top achievements
Rank 1
Iron
Share this question
or