This is a migrated thread and some comments may be shown as answers.

Workbook Find fails with Object reference not set to an instance of an object.

3 Answers 58 Views
SpreadStreamProcessing
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Iron
Iron
Veteran
Dan asked on 25 May 2020, 10:36 AM

I need to read the data from an excel file (not formatted) and in order to do this I need to find a cell that contains a specific text.

I am trying to do this

FindOptions options = new FindOptions()
{
    FindWhat = "Record",
    MatchEntireCellContents = true
};

but it fails with:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.Windows.Documents.Spreadsheet.Utilities.FindAndReplaceHelper.MoreThan(WorksheetCellIndex left, WorksheetCellIndex right, FindBy searchBy)
   at Telerik.Windows.Documents.Spreadsheet.Utilities.FindAndReplaceHelper.<>c__DisplayClass3_0.<OrderResults>b__0(FindResult result)
   at System.Linq.Enumerable.TakeWhileIterator[TSource](IEnumerable`1 source, Func`2 predicate)+MoveNext()
   at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
   at Telerik.Windows.Documents.Spreadsheet.Utilities.FindAndReplaceHelper.OrderResults(FindOptions findOptions, IEnumerable`1 findResults)
   at Telerik.Windows.Documents.Spreadsheet.Model.Workbook.Find(FindOptions findOptions)

While looking in the code I have discovered that is because the StartCell is null. Where does it say that the StartCell is mandatory? Also why is the StartCell mandatory?

3 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 26 May 2020, 09:41 AM

Hi Dan,

I was able to reproduce this and it is considered an issue. I have logged it on our feedback portal. You can track its progress, subscribe to status changes, and add your comment to it here. I have updated your Telerik points as well.

Until this is resolved you will need to set the StartCell as a workaround.

Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Dan
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 26 May 2020, 10:13 AM

Hi Dimitar,

Thank you for the feedback and for the solution. As a workaround I used FindAll and got the first.

0
Dimitar
Telerik team
answered on 27 May 2020, 06:03 AM

Hi Dan,

I am glad that you have found a workaround for your case. Do not hesitate to contact us if you have other questions.

Regards,
Dimitar
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
SpreadStreamProcessing
Asked by
Dan
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Dimitar
Telerik team
Dan
Top achievements
Rank 1
Iron
Iron
Veteran
Share this question
or