Skip to content
This repository has been archived by the owner on Jul 25, 2021. It is now read-only.

Data in cell: string became date #82

Open
mtweb opened this issue Aug 22, 2017 · 7 comments
Open

Data in cell: string became date #82

mtweb opened this issue Aug 22, 2017 · 7 comments

Comments

@mtweb
Copy link

mtweb commented Aug 22, 2017

When data in cell (table html) like that: Phong 8
And when I export to XLSX that cell (has data: Phong 8) => 7/31/2001 (in this cell of excel file).

Please check and help for me. Thanks you.

@cpatters9
Copy link

I ran into this as well - anything that can be successfully parsed as a date by Javascript's Date.parse() will be interpreted as a date, and Date.parse() is extremely forgiving.

You can work around this by overriding the date.assert function:

	var tableExporter = $('#myTable').tableExport();
	tableExporter.types.date.assert = function(v){return false;};

So you can either completely disable automatic date detection, as in this example, or you can write your own assert function to be as strict as you want. If you do this, you can still explicitly designate a cell as a date using the tableexport-date CSS class.

@dreamerblue
Copy link

@cpatters9 Thanks! I have also encountered the same issue, and your solution is really helpful.

@Dadidam
Copy link

Dadidam commented Feb 28, 2018

@cpatters9, tableExport object has no types value. So, I'm not able to override anything.

I use 5.x version. Any ideas?

@cpatters9
Copy link

Sorry @Dadidam, I haven't yet used 5.x. The above comment was based on version 3.3.13.

@Dadidam
Copy link

Dadidam commented Feb 28, 2018

@cpatters9 oh, thanks. Will try that hook on 3.x version. Thanks for your help!

@thibaultchazal
Copy link

Hi, I'm having the same issue with 5.x version.

Does anyone find a solution for this ? Or do you all downgrade to 3.x ?

@attilaancsin
Copy link

Hi everyone!
I was able to use @cpatters9's solution in version 5.0 with te following line:
TableExport.prototype.typeConfig.date.assert = function(value) { return false; };

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants