Allow to enforce text data format in written sheets
LoadingByte opened this issue · 1 comments
Spreadsheet editors often interpret data input by the users in ways they are not supposed to. This can be prevented by setting the cell's data format to "text", or, as it is usually called, "@". For my use case, I'd really like to set this data format in the sheets written by SODS.
On the XML side, this is easy to do. Just define the following number:text-style
element, and then reference it from cell styles:
<number:text-style style:name="textstyle">
<number:text-content />
</number:text-style>
...
<style:style style:family="table-cell" style:name="cel0" style:data-style-name="textstyle" />
Implementation-wise, I'd suggest always writing the new textstyle
style into the spreadsheet like you are already doing with <number:date-style style:name="datestyle">
at the moment. Then add an API like Style::setRawText(boolean)
or, if you want a more forward compatible API, Style::setDataStyle(String)
which only accepts "@"
at this point. If this option is set by the user, the style:data-style-name="textstyle"
attribute is added to the style's XML element.
I'd be very happy to hear your thoughts on this.
Makes sense to me. I'd rather the second option since it could be extended later.
We can always default to "@" if that's the most sensible value.