ByteScout Spreadsheet SDK - C# - Set Number Format In Cells - ByteScout

ByteScout Spreadsheet SDK – C# – Set Number Format In Cells

  • Home
  • /
  • Articles
  • /
  • ByteScout Spreadsheet SDK – C# – Set Number Format In Cells

How to set number format in cells in C# with ByteScout Spreadsheet SDK

How to code in C# to set number format in cells with this step-by-step tutorial

ByteScout tutorials are designed to explain the code for both C# beginners and advanced programmers. ByteScout Spreadsheet SDK can set number format in cells. It can be used from C#. ByteScout Spreadsheet SDK is the SDK that can write and read, modify and calculate Excel and CSV spreadsheets. Most popular formulas are supported. You may import or export data to and from CSV, XML, JSON as well as to and from databases, arrays.

You will save a lot of time on writing and testing code as you may just take the C# code from ByteScout Spreadsheet SDK for set number format in cells below and use it in your application. Just copy and paste the code into your C# application’s code and follow the instruction. Implementing C# application typically includes multiple stages of the software development so even if the functionality works please test it with your data and the production environment.

You can download free trial version of ByteScout Spreadsheet SDK from our website to see and try many others source code samples for C#.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

Program.cs
      
using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; using Bytescout.Spreadsheet; using System.IO; namespace HelloWorld { class Program { static void Main(string[] args) { // Create new Spreadsheet Spreadsheet document = new Spreadsheet(); // Get worksheet by name Worksheet worksheet = document.Workbook.Worksheets.Add("Sample"); // Set header worksheet.Cell(0, 0).Value = "Value (Number)"; worksheet.Cell(0, 1).Value = "Formatting String"; // Set variables double plan = 3000; double result = 3100; // Fill cells for (int i = 1; i < 6; i++) { worksheet.Cell(i, 0).Value = result / plan; } // Set cells format worksheet.Cell(1, 0).NumberFormatString = "0.00"; worksheet.Cell(2, 0).NumberFormatString = "0.00%"; worksheet.Cell(3, 0).NumberFormatString = "mm:ss"; worksheet.Cell(4, 0).NumberFormatString = "hh:mm:ss"; worksheet.Cell(5, 0).NumberFormatString = "##0,0E+0"; // Set captions worksheet.Cell(1, 1).Value = "0.00"; worksheet.Cell(2, 1).Value = "0.00%"; worksheet.Cell(3, 1).Value = "mm:ss"; worksheet.Cell(4, 1).Value = "hh:mm:ss"; worksheet.Cell(5, 1).Value = "##0,0E+0"; // delete output file if exists already if (File.Exists("Sample.xls")){ File.Delete("Sample.xls"); } // Save document document.SaveAs("Sample.xls"); // Close document document.Close(); // open generated XLS document in default program Process.Start("Sample.xls"); } } }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Spreadsheet SDK Home Page

Explore ByteScout Spreadsheet SDK Documentation

Explore Samples

Sign Up for ByteScout Spreadsheet SDK Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Spreadsheet SDK Home Page

Explore ByteScout Spreadsheet SDK Documentation

Explore Samples

Sign Up for ByteScout Spreadsheet SDK Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next