Author Topic: Export xlsx file  (Read 481 times)

STEVE

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 50
    • View Profile
Export xlsx file
« on: July 09, 2022, 06:28:09 am »
Dear paramvir,

I want to know how to prevent this html tag when I export excel file?

Quote

 In downloaded excel file, it has this like <button type='button' class='delete_btn'>Delete</button>


Best regards,
Steve.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6210
    • View Profile
Re: Export xlsx file
« Reply #1 on: July 11, 2022, 09:52:30 am »
it can be prevented by adding exportRender: false to the column.

https://paramquery.com/pro/api#option-column-exportRender

STEVE

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 50
    • View Profile
Re: Export xlsx file without html tag
« Reply #2 on: July 21, 2022, 06:43:37 pm »
I put it after sortable: false. 
But it didn't work at all.

Code: [Select]
                    title: "", editable: false, minWidth: 83, sortable: false, exportRender: false,
                    render: function (ui) {
                        return "<button type='button' class='delete_btn'>Delete</button>";
                    },
                    postRender: function (ui) {
                        var rowIndx = ui.rowIndx,
                            grid = this,
                            $cell = grid.getCell(ui);

                        $cell.find("button").button({ icons: { primary: 'ui-icon-scissors' } })
                        .bind("click", function () {

                            grid.addClass({ rowIndx: ui.rowIndx, cls: 'pq-row-delete' });

                            setTimeout(function () {
                                var ans = window.confirm("Are you sure to delete row No " + (rowIndx + 1) + "?");
                                grid.removeClass({ rowIndx: rowIndx, cls: 'pq-row-delete' });
                                if (ans) {
                                    grid.deleteRow({ rowIndx: rowIndx });
                                }
                            })
                        });
                    }

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6210
    • View Profile
Re: Export xlsx file
« Reply #3 on: July 22, 2022, 02:31:17 pm »
It works fine, can be verified by adding this in the toolbar of this example: https://paramquery.com/pro/demos/editing_batch

Code: [Select]
{
type: 'button',
label: "Export",
icon: 'ui-icon-arrowthickstop-1-s',
listener: function () {
this.exportData({
url: "/pro/demos/exportData",
format: "xlsx",
render: true
});
}
},

and adding exportRender: false, to the last column.



Which version of pqgrid you have been using?