ByteScout Spreadsheet SDK - C# - Set Cell Alignment - ByteScout

ByteScout Spreadsheet SDK – C# – Set Cell Alignment

  • Home
  • /
  • Articles
  • /
  • ByteScout Spreadsheet SDK – C# – Set Cell Alignment

How to set cell alignment in C# and ByteScout Spreadsheet SDK

The tutorial shows how to set cell alignment in C#

Set cell alignment is easy to implement in C# if you use these source codes below. What is ByteScout Spreadsheet SDK? It 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. It can help you to set cell alignment in your C# application.

C# code samples for C# developers help to speed up coding of your application when using ByteScout Spreadsheet SDK. This C# sample code is all you need for your app. Just copy and paste the code, add references (if needs to) and you are all set! Use of ByteScout Spreadsheet SDK in C# is also explained in the documentation included along with the product.

ByteScout free trial version is available for download from our website. It includes all these programming tutorials along with source code samples.

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 Bytescout.Spreadsheet; using System.Diagnostics; using System.IO; namespace HelloWorld { class Program { static void Main(string[] args) { // Create new Spreadsheet Spreadsheet document = new Spreadsheet(); // Add new worksheet Worksheet worksheet = document.Workbook.Worksheets.Add("AlignmentDemo"); // Set Values worksheet.Cell("A1").Value = "Name"; // setting centered alignment for the cell worksheet.Cell("A1").AlignmentHorizontal = Bytescout.Spreadsheet.Constants.AlignmentHorizontal.Centered; worksheet.Cell("B1").Value = "Full Name"; // setting centered alignment for the cell worksheet.Cell("B1").AlignmentHorizontal = Bytescout.Spreadsheet.Constants.AlignmentHorizontal.Centered; worksheet.Cell("A2").Value = "Homer"; // setting justifiedalignment for the cell worksheet.Cell("A2").AlignmentHorizontal = Bytescout.Spreadsheet.Constants.AlignmentHorizontal.Right; worksheet.Cell("B2").Value = "Homer Jay Simpson"; // setting justified alignment for the cell worksheet.Cell("B2").AlignmentHorizontal = Bytescout.Spreadsheet.Constants.AlignmentHorizontal.Right; // set columns width worksheet.Columns[0].Width = 300; // A column worksheet.Columns[1].Width = 400; // B column // delete output file if exists already if (File.Exists("CellAlignment.xls")){ File.Delete("CellAlignment.xls"); } // Save document document.SaveAs("CellAlignment.xls"); // open XLS document in default XLS Excel documents application Process.Start("CellAlignment.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