Click here to Skip to main content
11,640,599 members (59,424 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
I am creating excel file and show the data by datatable fetch by c# code to sql server. the data is comming in non formated type like -1 ,1.23,1.3,3.5,4,6
i want to show it in the same format like
1.00
1.23
1.30
3.50
4.00
6.00

my code is here

HSSFWorkbook workBook = new HSSFWorkbook();
var sheet = workBook.CreateSheet("OverAll");
                       var rowIndex = 2;
var avgCellFormate = workBook.CreateDataFormat();
                        var dataFormate = avgCellFormate.GetFormat("0.00");
                        var avgCellStyle = workBook.CreateCellStyle();
                        avgCellStyle.DataFormat = dataFormate;


row14Cells = row14.CreateCell(2);
                               row14Cells.SetCellValue(dr["Average"].ToString());
                               row14Cells.CellStyle = avgCellStyle;


Please give me Solution.
Thanks....
Posted 3-Oct-12 2:19am

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Mika Wendelius 330
1 OriginalGriff 175
2 Afzaal Ahmad Zeeshan 130
3 CPallini 125
4 Sergey Alexandrovich Kryukov 94
0 Mika Wendelius 200
1 OriginalGriff 145
2 CPallini 115
3 jgakenhe 40
4 sasanka sekhar panda 30


Advertise | Privacy | Mobile
Web03 | 2.8.150731.1 | Last Updated 14 Jun 2014
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100