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

RadSpreadsheet - Copy - paste numeric values formatted as text from excel

2 Answers 237 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Giorgos
Top achievements
Rank 1
Giorgos asked on 02 Apr 2020, 09:46 AM

When doing a copy / paste of numeric values from excel to RadSpreadsheet initial zero values are lost. So, when I copy for example value 07657656 it gets pasted as 7657656.

Is there any workaround this behavior?

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter Milchev
Telerik team
answered on 03 Apr 2020, 09:54 AM

Hello Giorgos,

One option is to set the format of a given range to text.

Another option is to set the format of the pasted data as text using the OnClientPaste event of the Spreadsheet:

 <telerik:RadSpreadsheet runat="server" ID="RadSpreadsheet1" OnClientPaste="OnClientPaste"></telerik:RadSpreadsheet>
<script>
    function OnClientPaste(sender, args) {
        var clipboardData = args.get_clipboardContent().data;
        for (var i = 0; i < clipboardData.length; i++) {
            for (var j = 0; j < clipboardData[i].length; j++) {
                var cellData = clipboardData[i][j];
                cellData.format = "@";
            }
        }
    }
</script>

Regards,
Peter Milchev
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
Giorgos
Top achievements
Rank 1
answered on 03 Apr 2020, 04:43 PM
Thanks, I used OnClientPaste. It works very well. I tested it with about 6000 rows of pasted data.
Tags
Spreadsheet
Asked by
Giorgos
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Giorgos
Top achievements
Rank 1
Share this question
or