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

Spreadsheet import/export

1 Answer 1138 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Judd
Top achievements
Rank 2
Judd asked on 05 Oct 2017, 07:31 PM

I am having trouble understanding what exactly is going on here in the snippet below. 

I am attempting to upload a file to my web view spreadsheet but not save the file. What is going on with the ProxyURL, the "/kendo-ui/content/web/spreadsheet/products.json" and the "saveUrl: "/kendo-ui/spreadsheet/Upload". What do I need to change to allow the functionality to work locally for me while I am testing. 

 

In a gist. I want to, Upload a file, save the file, display the file, and export the file. I can't figure this out exactly.

$(function () {
        $("#spreadsheet").kendoSpreadsheet({
            excel: {
                // Required to enable Excel Export in some browsers
                proxyURL: "https://demos.telerik.com/kendo-ui/service/export"
            }
        });
 
        var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
 
        $.getJSON("/kendo-ui/content/web/spreadsheet/products.json")
            .done(function (sheets) {
                spreadsheet.fromJSON({ sheets: sheets });
            });
 
        var ALLOWED_EXTENSIONS = [".xlsx", ".csv", ".txt", ".json"];
 
        $("#upload").kendoUpload({
            async: {
                saveUrl: "/kendo-ui/spreadsheet/Upload"
            },
            multiple: false,
            localization: {
                "select": "Select file to import..."
            },
            select: function (e) {
                var extension = e.files[0].extension.toLowerCase();
                if (ALLOWED_EXTENSIONS.indexOf(extension) == -1) {
                    alert("Please, select a supported file format");
                    e.preventDefault();
                }
            },
            success: function (e) {
                // Load the converted document into the spreadsheet
                spreadsheet.fromJSON(e.response);
            }
        });
 
        $(".download").click(function () {
            $("#download-data").val(JSON.stringify(spreadsheet.toJSON()));
            $("#download-extension").val($(this).data("extension"));
        });
    });

1 Answer, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 09 Oct 2017, 10:50 AM

Hello Judd,

Enabling server-side export with Kendo Spreadsheet involves implementing the server-side code that handles the export and import. Following the demo code showcases the client-side code that is required. However, the server-side code should be additionally implemented. 

For that, you can read more here:

As for the  "/kendo-ui/content/web/spreadsheet/products.json", you need to have a JSON file on the server that serves the Spreadsheet data. 

You can also download the Kendo UI demos and investigate the code implemented there. The demo application can be downloaded either vie the Telerik Control Panel, or from the downloads section in your account in www.telerik.com

Regards,
Ianko
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Spreadsheet
Asked by
Judd
Top achievements
Rank 2
Answers by
Ianko
Telerik team
Share this question
or