Unplanned
Last Updated: 13 Oct 2023 15:29 by ADMIN
Michael
Created on: 11 Oct 2023 10:00
Category: Spreadsheet
Type: Bug Report
0
SetValue to a Cell with a large Numeric only String is Infinity

We have a problem creating an Excel file with Telerik.Windows.Documents.Spreadsheet.

In our last release for our customers we used Telerik WPF version 22.2.613.40 (Spreadsheet DLL) When calling the following line of code

m_Worksheet.Cells[m_CurrentRowIndex, m_CurrentColumnIndex].SetValue("111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111111111111111"); the CellValueType is set to text and the Value is correct. We have now switched our project to .NET 7 and Telerik WPF to version 2023.2.519.70. We discovered that this line of code no longer works. The CellValueType is now Number and the Value Infinity Have you changed anything internally? How can we solve the problem now?


5 comments
ADMIN
Nikolay Demirev
Posted on: 13 Oct 2023 15:29

Hello Michael,

Usually, we try to fix the bugs our clients report immediately, but this one would require some research because it may break parsing values if not implemented correctly. I have logged it into our backlog. Please follow this public item to be notified when its status changes.

Regards,
Nikolay Demirev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Michael
Posted on: 13 Oct 2023 08:18
This was previously interpreted differently internally.

Based on the example, CellValueType = Text was previously automatically set for values ​​greater than double.MaxValue

Can't this be implemented again in such a way that we don't have to check it again?
Internally you also check what should happen to the string.

The workaround also works, of course, but if you took this into account internally again, you wouldn't need the workaround.
ADMIN
Nikolay Demirev
Posted on: 13 Oct 2023 08:04

Hello Michael,

Internally part of the parsing algorithm uses double.TryParse to check if a value is a number. Parsing this long number as a number instead of failing to parse it is a behavioral-breaking change in the .NET Framework. See the attached project.

As a workaround, you can use the SetValueAsText method of the CellSelection or set the NumberFormat for that cell to be Text ("@").

Regards,
Nikolay Demirev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Attached Files:
Michael
Posted on: 12 Oct 2023 14:02
In my post here I see spaces in the string. These are not included in my test, but simply over 600 characters with a 1. That's why you get a different result.
ADMIN
Nikolay Demirev
Posted on: 12 Oct 2023 13:55

Hello Michael,

I have tested setting the same value in a test project using en-US culture. Here is the code I am using:

Workbook workbook = new Workbook();
var sheet = workbook.Worksheets.Add();

sheet.Cells[0, 0].SetValue("111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111111111111111");

var value = sheet.Cells[0, 0].GetValue();

Debug.Assert(value.Value.ValueType == CellValueType.Text);

The cell value type is Text. Could you test it on your end? Are you using a different culture? Does the cell has any cell format?

I am looking forward to your reply.

Regards,
Nikolay Demirev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.