ByteScout Spreadsheet SDK - VBScript - Merge Cells and Set Alignment - ByteScout

ByteScout Spreadsheet SDK – VBScript – Merge Cells and Set Alignment

  • Home
  • /
  • Articles
  • /
  • ByteScout Spreadsheet SDK – VBScript – Merge Cells and Set Alignment

How to merge cells and set alignment in VBScript and ByteScout Spreadsheet SDK

How to code in VBScript to merge cells and set alignment with this step-by-step tutorial

These sample source codes on this page below are demonstrating how to merge cells and set alignment in VBScript. 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. It can merge cells and set alignment in VBScript.

Fast application programming interfaces of ByteScout Spreadsheet SDK for VBScript plus the instruction and the code below will help you quickly learn how to merge cells and set alignment. In your VBScript project or application you may simply copy & paste the code and then run your app! Code testing will allow the function to be tested and work properly with your data.

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

Try it today: Get 60 Day Free Trial or sign up for Web API

MergeCellsAndSetAlignment.vbs
      
Set document = CreateObject("Bytescout.Spreadsheet.Spreadsheet") document.RegistrationName = "demo" document.RegistrationKey = "demo" ' Add new worksheet Set worksheet = document.Workbook.Worksheets.Add("HelloWorld") ' change width of the column #1 set column = worksheet.columns.Item(1) column.Width = 200 ' change height of row #1 set row = worksheet.rows.Item(1) row.Height = 100 ' Merge cells Set range = worksheet.Range_2("A1:D5") range.Merge() ' Write text Set cell = worksheet.Cell_2("A2") set leftCell = cell.MergedWithCell() leftCell.ValueAsHTML = "<center><b>Bold text</b> and <i>Italic text</i></center>" ' set alignment ' setting right alignment for the cell leftcell.AlignmentHorizontal = 3 ' see (0) Bytescout.Spreadsheet.Constants.AlignmentHorizontal.Right ' delete output file if exists already Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FileExists("Output.xls")) Then fso.DeleteFile("Output.xls") Set fso = nothing ' save document document.SaveAs "Output.xls" ' close Spreadsheet Set document = Nothing

Try it today: Get 60 Day Free Trial or sign up for Web API

MORE INFORMATION

Get 60 Day Free Trial or Visit ByteScout Spreadsheet SDK page

Explore ByteScout Spreadsheet SDK documentation

WEB API VERSION

Sign Up for free Web API key

Explore Web API Documentation

Tutorials:

prev
next