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

Pasting "13-1.1" into a cell sets it to " 36904"

3 Answers 17 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Jannik
Top achievements
Rank 1
Jannik asked on 04 May 2015, 11:47 AM

Hello,

when I am  pasting  "13-1.1" into a cell, it sets the cell to " 36904".

Cell formats I tried:

sheet.Cells[row, columnIndex.Index].SetFormat(new CellValueFormat("@"));

sheet.Cells[row, columnIndex.Index].SetFormat(CellValueFormat.GeneralFormat);

Could you try to reproduce it and tell me, if its a bug?

Jannik

3 Answers, 1 is accepted

Sort by
0
Anna
Telerik team
answered on 07 May 2015, 08:35 AM
Hello Jannk,

If you try doing the same in Excel, you will notice that the result is the date 13.01.2001 and the underlying number representation of this date is 36904. RadSpreadsheet, just as Excel does, parses the value 13-1.1 into a date, but doesn't apply the date format and this is why the result is 36904, instead of 13.01.2001. In other words, changing the value to a date is expected behavior when the culture of the machine is set to German.

If you would like to avoid this behavior, both in Excel and RadSpreadsheet, you need to perform two steps:

1. Set the format of the cell to text, either though code or through the UI, just as you did in the code you shared.
sheet.Cells[row, columnIndex.Index].SetFormat(new CellValueFormat("@"));

2. Enter in edit mode of the cell and only then paste the value. This way you avoid the paste command, which parses the value even before it reaches the cell. Instead of this, you will use the paste functionality of the cell editor, which will not attempt to parse it. When you exit edit mode, the value will be parsed, but the text format which we set in step 1. will prevent it from parsing to a date.

I hope this explanation will be helpful and suitable for your scenario. Please, let me know if you have further questions or concerns.

Regards,
Anna
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Jannik
Top achievements
Rank 1
answered on 12 May 2015, 11:48 AM

Hello Anna,

thanks for the reply.

Is there any way to avoid this behaviour? I would love to see it always act like I am in edit mode,.

Best regards

Jannik

0
Anna
Telerik team
answered on 13 May 2015, 10:22 AM
Hello,

Unfortunately there is no way to avoid this particular behavior other than using the steps I described or changing the culture of the machine (for example to English - United States).

Regards,
Anna
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Spreadsheet
Asked by
Jannik
Top achievements
Rank 1
Answers by
Anna
Telerik team
Jannik
Top achievements
Rank 1
Share this question
or