Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 861
  • Last Modified:

Gridview number format disappears on export to excel

I am trying to export a gridview to excel with the same formatting that is in my gridview but my formatting is stripped out on the export.

I am loading a gridview with ObjectDataSource.  In the ObjectDataSource I load the data into a dataset with some custom string formating like this:

GridViewField = string.Format("{0:0000000}.{1:00}", numberOne, numberTwo);

It works fine when I view my gridview in the web browser but when I export to excel the numbers are not with this formatting.  How can I force the formatting to be the same for the export to excel?  
0
deloused
Asked:
deloused
  • 2
  • 2
1 Solution
 
Munawar HussainPrincipal Software EngineerCommented:
hi,

as you are exporting to Excel then you should ask excel to use its own formatting instead the HTML formatting as that is for browser not for excel

here is an example to use MS office (excel formatting with prefix mso)

http://www.agoric.com/sources/software/htmltoExcel


-thanks
0
 
delousedAuthor Commented:
That sounds like what I need.  What I'm trying to find out though is how to attach that formatting to my gridview cell.  Any ideas on that?
0
 
delousedAuthor Commented:
I found it!

http://geekswithblogs.net/AzamSharp/archive/2006/08/12/87804.aspx

needo_jee, you gave me the correct idea to search and this article further explains how to use it with a gridview like I needed.  Thanks for your help!
0
 
Munawar HussainPrincipal Software EngineerCommented:
~welcome
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now