Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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();
C#
var sheet = workBook.CreateSheet("OverAll");
                       var rowIndex = 2;

C#
var avgCellFormate = workBook.CreateDataFormat();
                        var dataFormate = avgCellFormate.GetFormat("0.00");
                        var avgCellStyle = workBook.CreateCellStyle();
                        avgCellStyle.DataFormat = dataFormate;



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



Please give me Solution.
Thanks....
Posted

1 solution

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900