tags:

views:

27

answers:

1

I'm exporting (by that I mean using the contentType) an aspx page to excel. It works fine, except for when the value is like 1/6.

Instead of excel displaying 1/6. It's displaying 6-Jan. Is there something in c# that I can put around the value being exported that says, keep this value a fraction when it is a fraction?

Thanks.

A: 

From what I understand Excel stores all values as numbers internally and is the difference between the differnt value types in Excel purely based on formatting.

I think you'd have to explicitly set the format on the Cell in Excel where you will be storing the value.

I don't know if you are completely creating the Excel file from scratch in the export or if you are filling a template with the values, but that's what I'd look into first. Try and set the cell's number format programmatically in the first case and simply update your template in the latter.

Hope that helps.

Anton
Yea, I'm creating the Excel dynamically via the Response.ContentType in the aspx page. The aspx page will have different data on it at times, so I can't really say to Excel, set colum A13 for example as Text. Because it might not be A13 tomorrow, maybe it's B10. Know what I mean? I was hoping there was something in C# that would force it to stay as a fraction. But it sounds like this is more on the Excel side of things. Hmm...
d3020