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.
On-demand (REST Web API) version:
Web API (on-demand version)
On-premise offline SDK for Windows:
60 Day Free Trial (on-premise)
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"); } } }
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
Get Your API Key
Explore Web API Docs
Explore Web API Samples
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
Get Your API Key
Explore Web API Docs
Explore Web API Samples
also available as: