0

I'm creating a workbook in Excel using Open XML, which works fine - except dates. Working in Excel you can change a cell's datatype like this: Right click the cell, format cell, in the number tab choose "date" (from the category section). I'd like to accomplish the same thing using C# and Open XML to create the workbook, however my date cells are shown as "general" (text) in Excel.

The date format is OK, it's presented like this: 01.01.2015. What I need is the cell type to be set to Date, so that I can filter by "January", not the string "01.01.2015".

When saving my Excel sheet as an .xml, I find that the cell is stored like this:

<Cell><Data ss:Type="String">04.09.2015 22:00:41</Data></Cell>

What I need is this:

<Cell ss:StyleID="s62"><Data ss:Type="String">04.09.2015 22:00:41</Data></Cell>

The bottom row is from a cell where I manually manipulated the data type to a Date.

I've used the examples where you create your own styles, the cell type is still a string when opened in Excel.

pnuts
  • 58,317
  • 11
  • 87
  • 139
Hanne Smith
  • 207
  • 2
  • 9
  • Show us what you have tried so far. – varocarbas Sep 05 '15 at 09:25
  • My bad, the xml was missing from my post. Edited it, not sure if I added the xml correctly. Anyhow, to answer your question - I cant post the thing I'm working on but I can add a – Hanne Smith Sep 05 '15 at 09:44
  • Then perhaps we might have a problem here. You know? Some of the SO answerers don't like too much questions of the lines of "here is my problem, solve it for me"; they prefer to see some effort and questions focused on well-delimited problems which are not too straightforward. You might be lucky and find some help (but it will certainly not be me). – varocarbas Sep 05 '15 at 09:49
  • Well that's nice. If you'd given me a few more minutes you'd find my post updated with a similar project. What I was going for in my previous answer until I found that enter actually posts my reply instead of giving me a line break, was that I can't post what I am working on, but I can post a smilar thing. I agree that a lot of the posts on this site are "I'm stuck, help me", but that wasn't what I was going for ;) Care to take a peek if I actually do share some code? And while I'm at it - how on earth do I get line breaks in the comment section? – Hanne Smith Sep 05 '15 at 09:55
  • OK. Apparently, comments do not allow line breaks: http://meta.stackexchange.com/questions/197/how-about-newlines-within-comments?lq=1 – varocarbas Sep 05 '15 at 10:05
  • http://stackoverflow.com/questions/981655/how-to-represent-a-datetime-in-excel – Ivan Stoev Sep 05 '15 at 11:10

0 Answers0