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

Pasting 100,000 cell in RadSpreadsheet works on localhost but not on the server

1 Answer 59 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Sara
Top achievements
Rank 1
Sara asked on 10 Oct 2019, 04:20 PM

I have a Radspreadsheet with 13 columns. I need to create a datatable with the grid content and send it to a stored procedure. When I paste 8000+ rows in the grid everything works fine on local host, but it doesn't seem to be able to create the datatable when I deploy on the server. Could it be that the data size is too big to be sent to the server? Is there anyway to overcome this problem?

I have two javascript methods: one to automatically save the grid content after pasting data in the grid, and one to format grid content as text. 

Here are the two JS methods:

        function OnClientChange(sender, eventArgs) {
            //call save automatically when posting any data in the grid
            var sheet = $find('<%=RadSpreadsheet1.ClientID%>');
            sheet.save();
        }

        function onclientpaste(sender, args) {

             //format data as text
            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 = "@"
                }
            }
        }

Here is the Radspreadsheet code:

<telerik:RadSpreadsheet runat="server" ID="RadSpreadsheet1" OnClientChange="OnClientChange" onclientpaste="onclientpaste">

1 Answer, 1 is accepted

Sort by
0
Peter Milchev
Telerik team
answered on 15 Oct 2019, 10:28 AM

Hello Sara,

Attached you can find a sample project that shows how to load and save the workbook via JSON in hidden field and also how to use the Spreadsheet document provider to load and save the data to a file. 

<script>
    function pageLoadHandler() {
        var spreadsheet = $find("<%= RadSpreadsheet1.ClientID %>");
        var value = $get("<%= HiddenField1.ClientID %>").value;
        var valueAsJSON = JSON.parse(value);

        spreadsheet.get_kendoWidget().fromJSON(valueAsJSON);
    }

    Sys.Application.add_load(pageLoadHandler);

    function OnClientClicked(sender, args) {
        var spreadsheet = $find("<%= RadSpreadsheet1.ClientID %>");
        var jsonstring = JSON.stringify(spreadsheet.get_kendoWidget().toJSON());
        $get("<%= HiddenField1.ClientID %>").value = jsonstring; 
    }
</script>

 

<asp:HiddenField ID="HiddenField1" runat="server" />
<telerik:RadButton runat="server" ID="RadButton1" Text="Postback" AutoPostBack="true" OnClick="RadButton1_Click" OnClientClicked="OnClientClicked" />
<telerik:RadSpreadsheet runat="server" ID="RadSpreadsheet1"></telerik:RadSpreadsheet>

 

public SpreadsheetDocumentProvider SpreadsheetProvider { get; set; }

protected void Page_Init(object sender, EventArgs e)
{
    var path = Server.MapPath("~/App_Data/spreadsheet.xlsx");
    SpreadsheetProvider = new SpreadsheetDocumentProvider(path);

    var workbook = new Telerik.Web.Spreadsheet.Workbook();
    workbook.Sheets = SpreadsheetProvider.GetSheets();

    var json = workbook.ToJson();
    HiddenField1.Value = json;

    //RadSpreadsheet1.Provider = provider;
}

protected void RadButton1_Click(object sender, EventArgs e)
{
    var workbook = Telerik.Web.Spreadsheet.Workbook.FromJson(HiddenField1.Value);
    SpreadsheetProvider.SaveWorkbook(workbook);

    // convert to DPL workbook if needed
    //var dplWorkbook = workbook.ToDocument();
}

Once the content is exported to a JSON string it can be transferred by any means the application finds suitable. Unfortunately, this is something outside our area of expertise and we might not be able to provide the most accurate approach for that. 

Usually, the IIS 7+ servers have built-in compression that is enabled by default. 

After all, the content you need to transfer is a string, so any approach that you can think of to transfer a long string from the client to the server and viceversa should work, as long as you have the whole correct string at the destination.

Regards,
Peter Milchev
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Spreadsheet
Asked by
Sara
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Share this question
or