ByteScout Data Extraction Suite - C# - Set number format in cells with spreadsheet sdk - ByteScout

ByteScout Data Extraction Suite – C# – Set number format in cells with spreadsheet sdk

  • Home
  • /
  • Articles
  • /
  • ByteScout Data Extraction Suite – C# – Set number format in cells with spreadsheet sdk

How to set number format in cells with spreadsheet sdk in C# with ByteScout Data Extraction Suite

How to write a robust code in C# to set number format in cells with spreadsheet sdk with this step-by-step tutorial

This sample source code below will display you how to set number format in cells with spreadsheet sdk in C#. ByteScout Data Extraction Suite is the bundle that includes three SDK tools for data extraction from PDF, scans, images and from spreadsheets: PDF Extractor SDK, Data Extraction SDK, Barcode Reader SDK. It can set number format in cells with spreadsheet sdk in C#.

This prolific sample source code in C# for ByteScout Data Extraction Suite contains various functions and other necessary options you should do calling the API to set number format in cells with spreadsheet sdk. IF you want to implement the functionality, just copy and paste this code for C# below into your code editor with your app, compile and run your application. Applying C# application mostly includes various 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 Data Extraction Suite 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 Data Extraction Suite Home Page

Explore ByteScout Data Extraction Suite Documentation

Explore Samples

Sign Up for ByteScout Data Extraction Suite 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 Data Extraction Suite Home Page

Explore ByteScout Data Extraction Suite Documentation

Explore Samples

Sign Up for ByteScout Data Extraction Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next