Solved

Gridview number format disappears on export to excel

Posted on 2009-04-14
4
848 Views
Last Modified: 2013-11-07
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
Comment
Question by:deloused
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
needo_jee earned 500 total points
ID: 24142026
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
 

Author Comment

by:deloused
ID: 24151174
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
 

Author Comment

by:deloused
ID: 24151690
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
 
LVL 12

Expert Comment

by:needo_jee
ID: 24155751
~welcome
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question