开发者

c# export excel maintain fraction value

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 expo开发者_如何学Crted that says, keep this value a fraction when it is a fraction?

Thanks.


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.


You can make "a trick". Start your string by char space in format HTML. https://www.utexas.edu/learn/html/spchar.html

Regards

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜