Initializes a new instance of CellRange.
public CellRange(int firstRow,int lastRow,int firstColumn,int lastColumn)
firstRow
Zero-based index of the first row in the cell range.
lastRow
Zero-based index of the last row in the cell range.
firstColumn
Zero-based index of the first column in the cell range.
lastColumn
Zero-based index of the last column in the cell range.
The CellRange constructor initializes a new CellRange object with the specified boundaries.
The boundaries define a rectangle of cells in a spreadsheet, starting from the firstRow and firstColumn to the lastRow and lastColumn.
This constructor does not perform any operations on the cells within the range itself. It merely defines the range, which can then be used in conjunction with spreadsheet manipulation methods.
using Leadtools;using Leadtools.Document.LEADOffice.Sheet;public void MergeCellsAndSaveExample(){// Load an Excel workbook from a filevar workbook = LEADWorkbookFactory.Create();// Add a new sheet named "MergeExample" or access an existing sheetvar sheet = workbook.CreateSheet("MergeExample");// Define the cell range to merge (e.g., A1:B1)var mergeRange = new CellRange(0, 0, 0, 1); // This assumes 0-based indexing for rows and columns// Perform the merge operation on the specified cell rangesheet.MergedRegions.AddRegion(mergeRange);// Optionally, set a value for the merged cellsvar cell = sheet.CreateRow(0).CreateCell(0); // Access the first cell in the merge rangecell.SetCellValue("Merged Cell");// Save the workbook to diskvar filePath = Path.Combine(LEAD_VARS.ImagesDir, @"MergedCells.xlsx");workbook.Save(filePath);Console.WriteLine($"Workbook saved with merged cells to {filePath}");}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";}