0

I would like to know how to successfully connect to spo service url with a IP address.

Connect-SPOService https://13.xxx.xxx.9-admin.sharepoint.com
212Coder
  • 7
  • 1
  • 7

1 Answers1

1

How about triggering the Excel export manually on button click using kendo.ooxml.Workbook combined with kendo.saveAs?

I have made up a Kendo Dojo example. Let me know if this is what you need. Additionally, if you need to retrieve the name of your screen, there are some examples of how to do this here

EDIT

Below is an example of the export generated by the Dojo example when the "Click to Export" button is pressed. Note that the title is custom.

Sample export with custom title

Not sure why this would not work for you, but try the following example with your code and see what happens. Basically, you can hook up the custom function to handle the export button click as follows:

$("#exportButton").kendoButton({
    click: function () {
       var grid = $("#yourGrid").getKendoGrid();

       // declare `rows` and supply your own column names
       var rows = [{
           cells: [
               { value: "ContactTitle" },
               { value: "CompanyName" },
               { value: "Country" }
           ]
       }];                        
       var trs = grid.dataSource;
       // will get any filters applied to grid dataSource
       var filteredDataSource = new kendo.data.DataSource({
           data: trs.data(),
           filter: trs.filter()
       });

       filteredDataSource.read();
       var data = filteredDataSource.view();

       for (var i = 0; i < data.length; i++) {
           var dataItem = data[i];
           rows.push({
               cells: [ // dataItem."Whatever Your Attributes Are"
                   { value: dataItem.ContactTitle },
                   { value: dataItem.CompanyName },
                   { value: dataItem.Country }
               ]
           });
       }                
       excelExport(rows);            
    }
});

This sets up the rows to be exported, and the excelExport function carries out the export:

function excelExport(rows) {
    var workbook = new kendo.ooxml.Workbook({
        sheets: [
            {
                columns: [
                  { autoWidth: true },
                  { autoWidth: true }
                ],
                title: "Name of Tab",
                rows: rows
            }
        ]
    });
    var nameOfPage = "Test-1"; // insert here however you are getting name of screen
    kendo.saveAs({ dataURI: workbook.toDataURL(), fileName: nameOfPage + " Export.xlsx" });

}

Let me know the outcome.

Sandman
  • 2,247
  • 1
  • 13
  • 26
  • I updated the question with the code and an explanation of what it is doing. Try this with your own code and let me know how it goes. – Sandman Jun 01 '17 at 08:32
  • Don't forget to accept (and vote up if you are happy with the solution :) ). Here is a link to the [toolbar-template tutorial](http://demos.telerik.com/kendo-ui/grid/toolbar-template) for Kendo grid. If you get stuck, post a new question (as it isn't related to this one) and remember to include as much detail as possible. – Sandman Jun 02 '17 at 14:17
  • I posted a new question. Hopefully you can help answer. – 212Coder Jun 05 '17 at 17:59