//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet = workbook.Worksheets[0]; var originalRange = worksheet.Range["B2:D4"]; originalRange.Merge(); originalRange.Value = "Original Range"; originalRange.Font.Bold = true; originalRange.Font.Color = Color.FromArgb(226, 231, 243); originalRange.Interior.Color = Color.FromArgb(145, 167, 214); originalRange.HorizontalAlignment = HorizontalAlignment.Center; originalRange.VerticalAlignment = VerticalAlignment.Center; // Set the offset of the range value and style. var offsetRange = worksheet.Range["B2:D4"].Offset(4, 4); offsetRange.Merge(); offsetRange.Value = "Offset Range"; offsetRange.Font.Bold = true; offsetRange.Font.Color = Color.FromArgb(226, 231, 243); offsetRange.Interior.Color = Color.FromArgb(56, 93, 171); offsetRange.HorizontalAlignment = HorizontalAlignment.Center; offsetRange.VerticalAlignment = VerticalAlignment.Center; // Save to an excel file workbook.Save("RangeOffset.xlsx");
' Create a new Workbook Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) With worksheet.Range("B2:D4") .Merge() .Value = "Original Range" .Font.Bold = True .Font.Color = Color.FromArgb(226, 231, 243) .Interior.Color = Color.FromArgb(145, 167, 214) .HorizontalAlignment = HorizontalAlignment.Center .VerticalAlignment = VerticalAlignment.Center End With ' Set the offset of the range value and style. With worksheet.Range("B2:D4").Offset(4, 4) .Merge() .Value = "Offset Range" .Font.Bold = True .Font.Color = Color.FromArgb(226, 231, 243) .Interior.Color = Color.FromArgb(56, 93, 171) .HorizontalAlignment = HorizontalAlignment.Center .VerticalAlignment = VerticalAlignment.Center End With ' save to an excel file workbook.Save("RangeOffset.xlsx")