.NET component
Read / Write / Generate Excel XLSX XLS files

Excel Jetcell .NET

• File formats: Excel Spreadsheet XLSX, XLS, CSV.
• 100% managed .NET component.
• Doesn't require Microsoft Excel.
• High performance (~50000 records per second).
• Plain & Fair licensing.
• Royalty-Free. No extra cost for Server license.
• 6 Months: Free Support + Free Updates.
Evaluation Version
Download  |   Online Demo
Developer License - $175
Buy now  |   Price List

Skip Navigation LinksUser Experience > Number Format

Excel Jetcell .NET component



Learning Resources




FREE version

News & Releases

May 20, 2016
Version 3.1 Update
Excel Jetcell .NET component
March 24, 2016
Version 3.1 Update
Excel Jetcell .NET component
January 29, 2016
Version 3.1 Update
Excel Jetcell .NET component
October 14, 2015
Version 3.1 Update
Excel Jetcell .NET component
March 03, 2015
Version 3.1 Update
Excel Jetcell .NET component
May 15, 2013
Version 3.1 Update
Excel Jetcell .NET component
November 15, 2012
Version 3.1 Update
Excel Jetcell .NET component

Cell Value format

"I want to set percentage value for excel cell. Is this possible?"
Brandon Long

If you want to write percentage value you need to set Style.StringFormat property.
User can set own format for cell value. Also you can set other value format: data, time, currency etc.
Class DefinedFormats has predefined set of common use formats.

  1. //Create a new workbook.
  2. ExcelWorkbook Wbook = new ExcelWorkbook();
  3.  
  4. //Add new worksheet to workbook.
  5. Wbook.Worksheets.Add("Sheet1");
  6.  
  7. //Sets columns width.
  8. Wbook.Worksheets[0].Columns[0].Width = 270;
  9. Wbook.Worksheets[0].Columns[1].Width = 15;
  10. Wbook.Worksheets[0].Columns[2].Width = 85;
  11. for (short i = 3; i < 40; i += 2)
  12. Wbook.Worksheets[0].Rows[i].Height = 10;
  13.  
  14. Wbook.Worksheets[0].Cells[0, 0].Value = "Demo of cell value of formats:";
  15. Wbook.Worksheets[0].Cells[2, 0].Value = "Value";
  16. Wbook.Worksheets[0].Cells[2, 2].Value = "Result";
  17.  
  18. Wbook.Worksheets[0].Cells[4, 0].Value = "Integer value, general format.";
  19. Wbook.Worksheets[0].Cells[4, 2].Value = 345;
  20. Wbook.Worksheets[0].Cells[4, 2].Style.StringFormat = "";
  21.  
  22. Wbook.Worksheets[0].Cells[6, 0].Value = "Integer value, financial format.";
  23. Wbook.Worksheets[0].Cells[6, 2].Value = 345;
  24. Wbook.Worksheets[0].Cells[6, 2].Style.StringFormat = "# ##0.00 $";
  25.  
  26. Wbook.Worksheets[0].Cells[8, 0].Value = "Integer value, numerical format.";
  27. Wbook.Worksheets[0].Cells[8, 2].Value = 345;
  28. Wbook.Worksheets[0].Cells[8, 2].Style.StringFormat = "0.00";
  29.  
  30. Wbook.Worksheets[0].Cells[10, 0].Value = "Integer value, percentage format(0.00%).";
  31. Wbook.Worksheets[0].Cells[10, 2].Value = 345;
  32. Wbook.Worksheets[0].Cells[10, 2].Style.StringFormat = "0.00%";
  33.  
  34. Wbook.Worksheets[0].Cells[12, 0].Value = "Integer value, exponential format(0.00E+00).";
  35. Wbook.Worksheets[0].Cells[12, 2].Value = 345;
  36. Wbook.Worksheets[0].Cells[12, 2].Style.StringFormat = "0.00E+00";
  37.  
  38. Wbook.Worksheets[0].Cells[14, 0].Value = "Double value, general format.";
  39. Wbook.Worksheets[0].Cells[14, 2].Value = 12345.6789;
  40.  
  41. Wbook.Worksheets[0].Cells[16, 0].Value = "Double value, fractional format(# ?/2).";
  42. Wbook.Worksheets[0].Cells[16, 2].Value = 12345.6789;
  43. Wbook.Worksheets[0].Cells[16, 2].Style.StringFormat = "# ?/2";
  44.  
  45. Wbook.Worksheets[0].Cells[18, 0].Value = "Double value, date format(MM-DD-YYYY).";
  46. Wbook.Worksheets[0].Cells[18, 2].Value = 12345.6789;
  47. Wbook.Worksheets[0].Cells[18, 2].Style.StringFormat = "MM-DD-YYYY";
  48.  
  49. Wbook.Worksheets[0].Cells[20, 0].Value = "Double value, time format(hh:mm).";
  50. Wbook.Worksheets[0].Cells[20, 2].Value = 98765.4321;
  51. Wbook.Worksheets[0].Cells[20, 2].Style.StringFormat = "hh:mm";
  52.  
  53. //Using predefined formats
  54. Wbook.Worksheets[0].Cells[22, 0].Value = "Predefined format, percentage value:";
  55. Wbook.Worksheets[0].Cells[22, 2].Value = 0.06;
  56. Wbook.Worksheets[0].Cells[22, 2].Style.StringFormat = DefinedFormats.Percentage;
  57.  
  58. Wbook.Worksheets[0].Cells[24, 0].Value = "Double value, time format(hh:mm).";
  59. Wbook.Worksheets[0].Cells[24, 2].Value = DateTime.Now.TimeOfDay;
  60. Wbook.Worksheets[0].Cells[24, 2].Style.StringFormat = DefinedFormats.Time_AMPM_One;
  61.  
  62. //Write .xls file.
  63. Wbook.WriteXLS(@"..\..\..\NumberStyle1.xls");
  64.  
  65. //Write .xlsx file.
  66. Wbook.WriteXLSX(@"..\..\..\NumberStyle.xlsx");
  67.  
  68. //Open specified file in MS Excel.
  69. System.Diagnostics.Process.Start(@"..\..\..\NumberStyle.xlsx");