Spreadsheet import/export

2 posts, 0 answers
  1. Judd
    Judd avatar
    2 posts
    Member since:
    Jul 2014

    Posted 05 Oct Link to this post

    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"));
            });
        });
  2. Ianko
    Admin
    Ianko avatar
    1729 posts

    Posted 09 Oct Link to this post

    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.
Back to Top