Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Fri May 24, 2024 12:00 pm

Can you share the code snippet how we can achieve the Cell.Offset() functionality using Spire.XLS
Is their any direct similar function in Spire XLS for that.

Like -- Interop.Excel having these type fuction , to get cells by providing offsets .
Offset(Optional RowOffset As Object = Nothing, Optional ColumnOffset As Object = Nothing) As Range


e.g. --cell.Offset(0, -4).Value

shekhar2024
 
Posts: 4
Joined: Fri May 24, 2024 11:51 am

Mon May 27, 2024 7:12 am

Hi,

Thank you for your inquiry and sorry to reply late for weekend.
Sorry we don't have an Offset() method, but you can refer to the code below to fulfill this requirement.

Code: Select all
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
CellRange cell = sheet.Range["A2"];

CellRange cell2 = sheet.Range[cell.Row + 2, cell.Column + 3];
cell2.Value = "Test";
Debug.WriteLine(cell2.RangeAddress);
workbook.SaveToFile("TestOffset.xlsx");


Sincerely,
Doris
E-iceblue support team
User avatar

Doris.Liu
 
Posts: 409
Joined: Mon Nov 07, 2022 8:10 am

Return to Spire.XLS