ByteScout Spreadsheet SDK - C# - Set Date Formatting in Cells - ByteScout

ByteScout Spreadsheet SDK – C# – Set Date Formatting in Cells

  • Home
  • /
  • Articles
  • /
  • ByteScout Spreadsheet SDK – C# – Set Date Formatting in Cells

How to set date formatting in cells in C# and ByteScout Spreadsheet SDK

The tutorial below will demonstrate how to set date formatting in cells in C#

The sample source codes on this page shows how to set date formatting in cells in C#. What is ByteScout Spreadsheet SDK? It is the library (SDK) that is capable of writing, reading, modifying and calculating Excel and CSV spreadsheets. Most popular formulas can be calculated and reculculated with Excel installed. You may import or export data to and from CSV, XML, JSON as well as to and from databases, arrays. It can help you to set date formatting in cells in your C# application.

This code snippet below for ByteScout Spreadsheet SDK works best when you need to quickly set date formatting in cells in your C# application. In your C# project or application you may simply copy & paste the code and then run your app! 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.

Download free trial version of ByteScout Spreadsheet SDK from our website with this and other source code samples for C#.

Try ByteScout Spreadsheet SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

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 captions worksheet.Cell(0, 0).Value = "#"; worksheet.Cell(0, 1).Value = "Date"; for (int i = 1; i < 8; i++) { // Set number worksheet.Cell(i, 0).Value = i; // Set current cell Cell currentCell = worksheet.Cell(i, 1); // Set date currentCell.ValueAsDateTime = DateTime.Now; // Set date format currentCell.NumberFormatString = "dd.mm.yyyy"; } // 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"); } } }

Try ByteScout Spreadsheet SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

VIDEO

ON-PREMISE VERSION INFORMATION

Get 60 Day Free Trial or Visit ByteScout Spreadsheet SDK Home Page

Explore ByteScout Spreadsheet SDK Documentation

Get ByteScout Spreadsheet SDK Free Training

WEB API

Get Your Free API Key

Explore Web API Documentation

Tutorials:

prev
next