Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
136 views
in Technique[技术] by (71.8m points)

javascript - OPEN option is not coming in Kendo Export to Excel using Jquery

I have a jquery function that exports the kendo grid data in a excel. I am able to export the data but I want a OPEN option along with SAVE and CANCEL once the excel is exported. Check the attached image for reference.

Here is my Jquery code to export data:

exportResultToExcel: function (data) {
       
            if (data.length > 0) {
                var rows = [{
                    cells: [
                        { value: "Payer", background: "#1F497D", color: "#fff" },
                        { value: "Acc No.", background: "#1F497D", color: "#fff" },
                        { value: "Draft No.", background: "#1F497D", color: "#fff" },
                        
                    ]
                }];
                for (var i = 0; i < data.length; i++) {
                    var dataItem = data[i];
                    rows.push({
                        cells: [
                          { value: dataItem.Customer },
                          { value: dataItem.AcNo) },
                          { value: dataItem.DtNo },
                        ]
                    })
                }
                var workbook = new kendo.ooxml.Workbook({
                    sheets: [
                      {
                          columns: [
                            { autoWidth: false },
                            { autoWidth: false },
                            { autoWidth: false },
                          ],
                          rows: rows
                      }
                    ]
                });
                var sheet = workbook.options.sheets[0];                              
                kendo.saveAs({ dataURI: workbook.toDataURL(), fileName: "Export Result.xlsx" });
            }

        })
    }, 
question from:https://stackoverflow.com/questions/65644180/open-option-is-not-coming-in-kendo-export-to-excel-using-jquery

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The download and the options are handled by the browser. It's depending on the browsers how it shows up.

IE's default is to show "save" and depending on the security settings have have an option for "Save as" and "Save and Open". IE File example

While Chrome downloads the file without any kind of message before hand. Once the file is downloaded it has options to "Open", "Always opens files of this type", and "Show in folder". Chrome file example


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...