Solved

Gridview number format disappears on export to excel

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

823 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