jszip error when trying to export to excel

jszip error when trying to export to excel

MaheshMarellaMaheshMarella Posts: 1Questions: 1Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown: I get this error: "Error: Module name "stream" has not been loaded yet for context: _. Use require([])"
Description of problem:
Getting above error and excel button not shown. I have followed order of loading libs as follows
- buttons
- jszip
- html5 buttons

Answers

  • jsonplusjsonplus Posts: 10Questions: 1Answers: 0

    i have same problem when use pdfmake.min.js
    What is module name stream??
    i cant found it!

  • jsonplusjsonplus Posts: 10Questions: 1Answers: 0

    im using require.js

    requirejs.config({
        "baseUrl": "js/lib",
        "paths": {
            "app": "../app",
            //"datatables.net": "../lib/datatables.min",
            "datatables.net": "../lib/jquery.dataTables.min",
            "datatables.net-buttons": "../lib/dataTables.buttons.min"
        },
        "shim": {
            "custom_js": ["jquery"],
        }
    });
    // Load the main app module to start the app
    requirejs(["app/showmy"]);
    

    If i remove comment on pdfmake.min my page give error:
    Error messages shown: I get this error: "Error: Module name "stream" has not been loaded yet for context: _. Use require([])"

    define([
        "jquery",
        "custom_leftbar",
        //"jquery.dataTables.min",
        "datatables.net",
        "datatables.net-buttons",
        "buttons.flash.min",
        "buttons.print.min",
        "jszip.min",
        //"pdfmake.min",
        "vfs_fonts",
        "buttons.html5.min"
    ], function($) {
        $(function() {
            //TO DO
            //$('body').addptodom();
           
        });
    });
    

    mypage.html

    ......
    .....
    <head>
        <script data-main="js/navbarSelected1" src="js/lib/require.js"></script>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content=""><meta name="author" content="">
    
        <title>Dashboard Template for Bootstrap</title>
    
        <link href="css/bootstrap.min.css" rel="stylesheet">
        <link href="css/dashboard.css" rel="stylesheet">
        <link href="css/jquery.dataTables.min.css" rel="stylesheet">
        <link href="css/buttons.dataTables.min.css" rel="stylesheet">
    
    
        <style>
        td.details-control {
            background: url('images/details_open.png') no-repeat center center;
            cursor: pointer;
        }
        tr.shown td.details-control {
            background: url('images/details_close.png') no-repeat center center;
        }
        </style>
    
        <!--[if lt IE 9]>
        <script src="js/lib/ie8-responsive-file-warning.js"></script>
        <![endif]-->
        <script src="js/lib/ie-emulation-modes-warning.js"></script>
        <!--//--><!--[if lt IE 9]>
        <script src="js/lib/html5shiv.min.js"></script>
        <script src="js/lib/respond.min.js"></script>
        <![endif]-->
    </head>
    
    <body>
    <script src="js/lib/jquery.min.js"></script>
    <script src="js/lib/bootstrap.min.js"></script>
    <script src="site.js"></script>
    
    .....
    .....
    
  • jsonplusjsonplus Posts: 10Questions: 1Answers: 0
    ....
        table = $('#mytable').DataTable( {
                   "scrollCollapse": true,
                   "paging": false,
                   "info": false,
                   "autoWidth": true,
                   "destroy": true,
                   "dom": "Bfrtip",
                   "buttons": [
                                 "copy", "csv", "excel", "pdf", "print"
                                ],
              ...
              ...
    

    and this is datatable

  • jsonplusjsonplus Posts: 10Questions: 1Answers: 0
    edited June 2020

    File 'Roboto-Regular.ttf' not found in virtual file system error including pdfmake.min.js
    after changed :
    https://nightly.datatables.net/buttons/js/dataTables.buttons.min.js

  • jsonplusjsonplus Posts: 10Questions: 1Answers: 0
    edited June 2020

    UPDATE
    using
    https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.65/pdfmake.js
    instead of pdfmake.min.js solve error but
    button PDF not work
    and button excel is not displayed
    button CSV not work with IE browser

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Hi,

    If you could give me a link to your page please I can take a look at it.

    Regarding the CSV issue, what version of IE are you using? It should work in IE10+ as noted in the docs - csvHtml5.

    Allan

  • jsonplusjsonplus Posts: 10Questions: 1Answers: 0
    edited June 2020

    Thank you for reply...
    this is my page:
    https://hastebin.com/fuwelidofo.xml

    im using ie 11 when i press button pdf or csv i have this message:
    impossible to download

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Allan meant a link to the page demonstrating the issue, not to the code. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • jsonplusjsonplus Posts: 10Questions: 1Answers: 0

    I suppose the problem is on require.js

    requirejs.config({
        "baseUrl": "js/lib",
        "paths": {
            "app": "../app",
            "datatables.net": "../lib/jquery.dataTables.min",
            "datatables.net-buttons": "../lib/dataTables.buttons.min"
        },
        "shim": {
            "custom_leftbar": ["jquery"],
        }
    });
    // Load the main app module to start the app
    requirejs(["app/showNavbar1"]);
    

    If i delete this two lines:

    "datatables.net": "../lib/jquery.dataTables.min",
    "datatables.net-buttons": "../lib/dataTables.buttons.min"
    

    I get this error:** "Error: Module name "stream" has not been loaded yet for context: _. Use require([])"**

    define([
        "jquery",
        "custom_leftbar",
        "jquery.dataTables.min",
        "dataTables.buttons.min",
        //"datatables.net",
        //"datatables.net-buttons",
        "buttons.flash.min",
        "buttons.print.min",
        "jszip.min",
        "pdfmake",
        "vfs_fonts",
        "buttons.html5.min"
    ], function($) {
        $(function() {
            //TO DO
            //$('body').addptodom();
            console.log('required plugins loading...');
            writeLeftBar("selB1");
            console.log('required plugins loaded...');
    
        });
    });
    
    

    https://github.com/PeppeGC/Datatable
    in dir 'not work' there is the page

  • jsonplusjsonplus Posts: 10Questions: 1Answers: 0
    edited June 2020

    ok you can find it in dir 'not working' on

    https://github.com/PeppeGC/Datatable

    in page ** orderTable - TODO.html ** i have include

    <script data-main="js/navbarSelected1" src="js/lib/require.js"></script>
    

    that use require.js

    function dt() is in js\lib\custom_leftbar.js (datatable)

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Again, that's a link to the code. Can you create a fiddle (such as http://live.datatables.net/) to demonstrate the problem, please.

    Colin

  • jsonplusjsonplus Posts: 10Questions: 1Answers: 0

    solved adding:
    window.JSZip = require('jszip.min');

    define([
        "jquery",
        "custom_leftbar",
        "jquery.dataTables.min",
        "dataTables.buttons.min",
        //"datatables.net",
        //"datatables.net-buttons",
        "buttons.flash.min",
        "buttons.print.min",
        "jszip.min",
        "pdfmake",
        "vfs_fonts",
        "buttons.html5.min"
    ], function($) {
            //Solution for missing Excel Button:
            //https://datatables.net/forums/discussion/49747/excel-button-not-showing-up-using-webpack
            window.JSZip = require('jszip.min');
            $(function() {
    
            });
    });
    
    
This discussion has been closed.