Click here to Skip to main content
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)



Advertise | Privacy | Mobile
Web02 | 2.8.140926.1 | Last Updated 14 Jun 2014
Copyright © CodeProject, 1999-2014
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