0

I have an Excel sheet. In that sheet, one of the column ( name as ID) has values with leading zeros. For example-
ID -- 000987654321

When I am generating XML from Excel, the leading zeros are getting dropped.

While generating XML, I tried to map it like -- <xsd:element name="ID" type="xsd:decimal" />

Need help with what datatype should I put so that the leading zeros do not get dropped while generating XML.

Sneha
  • 83
  • 1
  • 11
  • If you want to use a numeric type like `decimal` then it doesn't make sense to preserve the leading zeroes. Either use a string type, or lose the zeroes and re-add them when displaying the value. – jsheeran Jan 09 '20 at 11:17
  • @jsheeran string datatype also i tried, it is also not reserving leading zeros – Sneha Jan 09 '20 at 11:18
  • In Excel, are the zeroes part of the value or added by cell formatting? – jsheeran Jan 09 '20 at 11:20
  • I added by cell formatting, example -- values are ranging from 8 to 12 digits. However, I need 12 digits number, so I am appending the zeros by customzing cell formatting. I typed 000000000000 in the custom part of the cell format in Home Tab. Hence all the values become 12 digits. example - 87654321 will come 000087654321 , 987654321 becomes 000987654321 , 123456789123 remains 123456789123 – Sneha Jan 09 '20 at 11:31
  • You'll need to apply the same transformation to your XML as you are in the cell formatting. [This question](https://stackoverflow.com/questions/25662151/padding-number-with-leading-zeros-in-xslt-1-0) may be of relevance. – jsheeran Jan 09 '20 at 11:50
  • @jsheeran not really.. since my excel is now having correct values as expected, now i need to generate xml and i would need help with xml supported datatype for leading zeros – Sneha Jan 09 '20 at 12:11
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/205667/discussion-between-sneha-and-jsheeran). – Sneha Jan 09 '20 at 12:35

0 Answers0