.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

Excele sheet number format

Posted By: dotnetbubbles     Posted Date: October 12, 2010    Points:2   Category :Windows Application
Hi,

I am exporting some data to excel. i have one column which has the values like:
9.12356
5.8956
8.5647.

But my requirement is to display in the excel:
9.12
5.89
8.56

How to do thru c# code to get above out put?

Thanks in advance

Responses
Author: Asha.MP             
Posted Date: October 12, 2010     Points: 5   

Hi..

While exporting the data you can format the values right?


Thanks and Regards,
Asha.mp
Author: Sajid P K             
Posted Date: October 13, 2010     Points: 5   

Hi,

Follwing is the COde for formating the first Column of EXcel sheet. You Have to change the Column index of cell to format the required column

VB.NET

 
Dim Wb As Excel.Workbook =
Dim xWS As Excel.Worksheet
xWS = Wb.ActiveSheet
CType(xWS.Cells(1, 1 ), Excel.Range).EntireColumn.NumberFormat = "#,##0.00"


C#

 Excel.Workbook wb =    ;
Excel.Worksheet xWS;
xWS = wb.ActiveSheet;
Excel.Range rng = xWS.Cells[1,1 ] as Excel.Range;
rng.EntireColumn.NumberFormat = "#,##0.00";




Regards,
Sajid P K





Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend