Author Topic: Export working, except for .xlsx  (Read 119 times)

mikep

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 105
    • View Profile
Export working, except for .xlsx
« on: January 14, 2022, 11:23:06 pm »
I'm getting this error when exporting w/.xlsx. Any ideas? I'm using V.8

pqgrid.min.js:17 Uncaught TypeError: JSZip is not a constructor
    at Object.exportWb (pqgrid.min.js:17:13462)
    at e.cExport.Export (pqgrid.min.js:17:7559)
    at e.<computed>.<computed>.n.exportData (pqgrid.min.js:17:5121)
    at e.<computed>.<computed>.exportData (test.html:53:33)
    at e.<computed>.<computed>.action (test.html:224:48)
    at e.cContext.onclickDoc (pqgrid.min.js:16:314)
    at HTMLBodyElement.dispatch (jquery-2.2.4.min.js:3:7537)
    at HTMLBodyElement.r.handle (jquery-2.2.4.min.js:3:5620)

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5339
    • View Profile
Re: Export working, except for .xlsx
« Reply #1 on: January 14, 2022, 11:38:36 pm »
[ Only Pro members may read this post. ]

mikep

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 105
    • View Profile
Re: Export working, except for .xlsx
« Reply #2 on: January 14, 2022, 11:49:04 pm »
That's it. Thanks for quick response!!

mikep

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 105
    • View Profile
Re: Export working, except for .xlsx
« Reply #3 on: January 15, 2022, 12:47:48 am »
Including the file worked for .xlsx in my vanilla test page, but I'm getting this error in my app page when calling exportData: "Uncaught invalid color: gray at pqgrid.min.js.17"

Any ideas what to try next?

Here are  my script includes for the page:
    <script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
    <script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>

    <link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" />

    <script src="PQ/pqgrid.min.js"></script>
    <script src="PQ/pq-localize-en.js"></script>
    <script src="PQ/jszip.min.js"></script>
    <script src="PQ/FileSaver.js"></script>

    <link href="PQ/pqgrid.min.css" rel="stylesheet" />
    <link href="PQ/pqgrid.ui.min.css" rel="stylesheet" />
« Last Edit: January 15, 2022, 01:42:07 am by mikep »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5339
    • View Profile
Re: Export working, except for .xlsx
« Reply #4 on: January 17, 2022, 01:17:11 pm »
[ Only Pro members may read this post. ]

mikep

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 105
    • View Profile
Re: Export working, except for .xlsx
« Reply #5 on: January 21, 2022, 02:56:40 am »
Thanks, next issue for .xlsx.

It looks like the .xlsx file is ultimately formatted as html. I debugged the SaveAs method in FileSaver.js and the output appeared identical to my demo page, which successfully exports to .xlsx. I'm attaching the excel and js files for you review. Here's the javascript I'm using that calls the js File.

                var grid = $gridMain.pqGrid('instance');
                var blob = grid.exportData({
                    format: format,
                    render: true
                });

                if (typeof blob === "string") {
                    blob = new Blob([blob]);
                }
                saveAs(blob, "SMART_export." + format);



paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5339
    • View Profile
Re: Export working, except for .xlsx
« Reply #6 on: January 21, 2022, 11:11:19 am »
[ Only Pro members may read this post. ]

mikep

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 105
    • View Profile
Re: Export working, except for .xlsx
« Reply #7 on: January 21, 2022, 05:23:26 pm »
Thanks. I am exporting grid columns that have images, could this be causing the issue?
I have just set the those grid columns with: "exportRender:false", but when I export, these columns are still visible. Do I need to do something else so that the grid columns don't get exported?

mikep

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 105
    • View Profile
Re: Export working, except for .xlsx
« Reply #8 on: January 21, 2022, 07:39:56 pm »
Another question for .xlsx, attached is a screenshot showing csv and xlsx exports for the same grid. The csv is correctly only showing the columns visible in the grid, and .xlsx is showing more columns, the 1st column has no data in it and is on it's own row in excel. Also, I continue to get the attached error before opening the .xlsx file.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5339
    • View Profile
Re: Export working, except for .xlsx
« Reply #9 on: January 24, 2022, 10:51:36 am »
[ Only Pro members may read this post. ]
« Last Edit: January 24, 2022, 10:53:44 am by paramvir »