Author Topic: Export date type fields  (Read 2493 times)

seb

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 10
    • View Profile
Export date type fields
« on: November 16, 2018, 03:33:50 pm »
Hello,

When I export a grid with dates in a column, the dates appear as text in Excel, rather than a true date object. I have set the PQGrid column dataType: "date", so I thought this would have worked.

Please can you advise the correct method for exporting date columns?

Thank you,
Seb

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6297
    • View Profile
Re: Export date type fields
« Reply #1 on: November 16, 2018, 08:40:40 pm »
Dates are exported as date objects in the examples.

What's the complete date column definition in your case, specifically column.render and column.format.

seb

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Export date type fields
« Reply #2 on: November 16, 2018, 09:01:40 pm »
Hi,

My column model looks like this:

Code: [Select]
colModel: [
{ title: "Date Added", width: 100, dataType: "date", dataIndx: "date_of", format: "dd/mm/yy" }
]

My export code looks like this:

Code: [Select]
function exportGrid() {
var blob = $grid.pqGrid("exportData", {
url: "/api/excel/export.php",
format: "xlsx",
render: true,
type: "blob",
filename: "export",
sheetName: "Export"
});
}

But when I open the Excel file, the date has come through as a string, and I have to manually convert it to a date by couble-clicking in the cell.

Thanks,
Seb

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6297
    • View Profile
Re: Export date type fields
« Reply #3 on: November 17, 2018, 08:26:50 am »
Works fine for me with that column definition.

Any way to reproduce the issue in the demos or share a jsfiddle so that I can look into it.