jquerymodel-view-controllerjexcelapi

().jexcel not a function


I would like to ask why the console always prompt that "TypeError: $(...).jexcel is not a function" when i try to convert the data of the table in jexcel plugin into JSON. Here's my code:

  <a class="btn btn-info" id="showWidth" >Import Excel</a>
    <a class="btn btn-success" id="uploadOTexc">Upload OT's</a>
    <br>
    <br>
    <div class="widget widget-table action-table">
        <div class="widget-header">
            <i class="icon-th-list"></i>
            <h3>OT's</h3>
        </div>
        <div class="widget-content" id="totalwidth">

            <div id="xcls" class="table table-striped table-border">
            </div>
        </div>
        @*<textarea id='txt' style='width:400px;height:120px'></textarea>*@
    </div>
    <script type="text/javascript">
        var dynWidth = 227.2
        var data = [];
        for (var i = 0; i < 15; i++)
        {
            data.push({
                id: '',
                date: '',
                start: '',
                end: '',
                reason: '',
            })
        }

        $('#xcls').jexcel({
            data: data,
            colHeaders: ['EMPLOYEE ID', 'DATE APPLY', 'START TIME', 'END TIME', 'REASON'],
            colWidths: [195, dynWidth, dynWidth, dynWidth, dynWidth],
            //minDimensions:[10,5],
            columns: [
                { type: 'text' },
                 { type: 'text' },
                { type: 'text' },
                { type: 'text' },
                { type: 'text' },
            ]
        });

        $('#uploadOTexc').on('click', function ()
        {
            var data = $('#xcls').jexcel("getData");
        });
    </script>

by the way I use a jexcel plugin from bossanova. Thanks,


Solution

  • The javascript file is not loaded when you execute the script.