)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Syncfusion Feedback

How to custom print the multiple cell range in Spreadsheet

Platform: jQuery |
Control: ejSpreadSheet |
Published Date: March 15, 2018 |
Last Revised Date: May 22, 2019

Description

This knowledge base explains how to custom print the multiple cell range in Spreadsheet.

Solution

It can be achieved by using ‘customPrintSelection()’ extension method which is provided in the extension script (Custom-print-extension.min.js).

 

HTML

 

<script type="text/javascript" src="ej.web.all.min.js"></script>
<script src="Custom-print-extension.min.js" type="text/javascript"></script>
 
<input type="button" onclick="customPrintFunc()" value="Click here to Print" />
<div id="Spreadsheet"></div>

 

JS

 

var defaultData = [{ "Name": "VINET", "Average": 90, "Grade": "S" }, { "Name": "TOMSP", "Average": 83, "Grade": "A" }, { "Name": "HANAR", "Average": 80, "Grade": "A" }, { "Name": "VICTE", "Average": 93, "Grade": "S" }];
 
$("#Spreadsheet").ejSpreadsheet({
    sheets: [{
        dataSource: defaultData
    }],
    loadComplete: "loadComplete"
});

 

RAZOR

 

@(Html.EJ().Spreadsheet<object>("Spreadsheet")
    .Sheets(sheets =>
    {
        <!-- you can define the datasource at server side -->
        sheets.Datasource((IEnumerable)ViewBag.DataSource).Add();
    })
    .ClientSideEvents(
        events => events.LoadComplete("loadComplete")
    )
)

 

ASPX

 

<ej:Spreadsheet ID="Spreadsheet" runat="server">
    <Sheets>
        <ej:Sheet></ej:Sheet><!-- you can define datasource at server side -->
    </Sheets>
    <ClientSideEvents LoadComplete="loadComplete" />
</ej:Spreadsheet>

 

JS

 

function loadComplete(args) {
    //Here extend the ejSpreadsheet.Extension
    $.extend(this, ej.spreadsheetFeatures.extension);
 
    if (!this.isImport) {
        this.setWidthToColumns([{ colIndex: 0, width: 90 }, { colIndex: 1, width: 85 }, { colIndex: 2, width: 100 }, { colIndex: 11, width: 70 }]);
        this.XLChart.createChart("A1:B6", { type: "column", enable3D: false, marker: false, top: 40, left: 260, width: 340, height: 250 });
    }
}
 
function customPrintFunc() {
    var ssObj = $("#Spreadsheet").data("ejSpreadsheet");
 
    //If passed the chart date range, it'll will print chart after its cell data
    ssObj.customPrintSelection(["A1:C10", "A10:C13"]); //Here pass the cells ranges that you want to print.
}

 

 

You can download the custom script ‘custom-print-extension.min.js’ from below link,

 

Custom-print-extension

 

The following screenshot is displayed as the output of custom printing Spreadsheet with chart and its range data.

 

spreadsheet custom print sample preview

Figure:  Custom printing of Chart and its data range in Spreadsheet

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon