开发者

exporting to excel removes leading zeros. css styles to the table does not carry over to the excel export

开发者 https://www.devze.com 2023-03-26 12:03 出处:网络
I have an asp:table which I want to exported to excel. One of my fields are alpha numeric and when exported to excel the leading 0s are stripped off.

I have an asp:table which I want to exported to excel. One of my fields are alpha numeric and when exported to excel the leading 0s are stripped off.

Aft开发者_StackOverflow中文版er going through this thread: Validation (CSS 2.0): 'mso-number-format' is not a known CSS property name

I would like to use the css method "mso-number-format:\@;.But the css is not exported to excel.

I just tried to test it with simpler css things like bold font etc but its not getting carried over. I can see that if I surround my asp:Label with tags this change gets carried over to the excel but not the css bold .

Other solutions in other thread does not work for me as ="00111" shows up as desired in excel but in the web form it shows up as ="00111" which is not what i want.

Any ideas will be appreciated.

Thanks


I would need to see your export code to give an accurate answer, but you might want to try a String.Format({0:0#}, fieldStringData) when you are doing the export. This will ensure passing the string to excel will include the leading zero.


Thanks for all the inputs but that did not work for me. I just worked around it with a trick. In the requirement I had, I had to show SomeAccountNumber:000000111112222

So I worked around it by putting "SomeAccountNumber" in one label and ":" + "000000111112222 " in the other label.

I know its not the correct way to fix the problem but just worked for my case. Might help others to in similar scenarios.

0

精彩评论

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