- Exporting XML from Excel and Keeping Date Format
- 2 Answers 2
- how do i convert to an Excel file to xml file by uploading it using Javascript and call AJAX method?
- Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.
- Hot Network Questions
- Subscribe to RSS
- Convert Excel to XML in Node.js
- JavaScript Excel library installation#
- Convert Excel to XML in Node.js#
- Excel to XML conversion — advanced options#
- Get a Free License#
- Summing up#
- Ask a question#
- FAQs#
- See Also#
- groupdocs-cloud-gists / Convert_Excel_file_to_XML_format_in_NodeJs.js
Exporting XML from Excel and Keeping Date Format
Many StackOverflow posts and other online forums have questions similar to this, but none of them really resolve the issue I’m having. I’m exporting an XML file from Excel. The Excel file contains dates. In the XML file, however, those dates show up as integers—the date is made to be the nth day since 1/0/1900, I believe. I’m using JavaScript to extract the data from the XML file to populate a table in a web page. I suspect that a solution could come in two different forms: 1. A way to convert, in JavaScript, the integer to the date it represents. 2. A way to force the XML file to take a formatted date from the Excel file. I’m clearly a novice with XML and JavaScript, so your assistance would be sincerely appreciated. Thanks.
Do you have the ability to edit the Excel file or is there some reason it has to remain exactly as is before you export it?
2 Answers 2
The format Excel uses for the xml-export depends on the added XML-schema. This can be explicitly created and added or — as I suspect in your case — has been implicitly/ automatically generated by Excel.
In my example I have two colums, the first one has via XML-Schema to format date-time, the second is normal text and only for the representation in Excel (column format) a date.
When I export this as XML I get two seemingly completely different results:
2009-10-12T00:00:00.000 40098 2000-01-01T00:00:00.000 36526
When I check the XML-Schema (e.g. with «Debug.Print ActiveWorkbook.XmlMaps(1).Schemas(1).XML») I see the difference (only snippet, not the complete file):
The first column is in the schema of format datetime, the second is varchar. Again, you might not even be aware, how Excel handles your XML-data, since this schema is automatically generated (if I recall correctly in Excel 2003 there was a message indicating that an schema had benn generated for you)
Now how to acomplish this — especially in an existing file: I would try to extract the XML-Schema (see above), save it as something.xsd, adapt the schema according to your needs and import this new Schema. Bummer is you have to set the mapping again (or try this: Excel 2007 XML Source Maps — Refreshing Schemas). Often I let MS Access generate my XML-Schema, i.e. generate the required table, insert some values and exprt the table as XML (ticking the option to add the schema).
I hope this general outline gives you an idea on how to proceed.
how do i convert to an Excel file to xml file by uploading it using Javascript and call AJAX method?
I gone through some articles in the internet but i couldn’t find any way to convert excel file to xml format. But i have tried this code convert excel to json but i have stuck convert excel file to xml using javascript ,Below i have tried the code to convert excel to json. Can someone help me to convert to xml.