Solved

Gridview number format disappears on export to excel

Posted on 2009-04-14
4
843 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
  • 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now