//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet = workbook.Worksheets[0]; IRange rangeA1B2 = worksheet.Range["A1:B2"]; rangeA1B2.Merge(); rangeA1B2.Interior.Pattern = GrapeCity.Documents.Excel.Pattern.LinearGradient; (rangeA1B2.Interior.Gradient as ILinearGradient).ColorStops[0].Color = Color.Red; (rangeA1B2.Interior.Gradient as ILinearGradient).ColorStops[1].Color = Color.Yellow; (rangeA1B2.Interior.Gradient as ILinearGradient).Degree = 90; IRange rangeE1E2 = worksheet.Range["D1:E2"]; rangeE1E2.Merge(); rangeE1E2.Interior.Pattern = GrapeCity.Documents.Excel.Pattern.LightDown; rangeE1E2.Interior.Color = Color.Pink; rangeE1E2.Interior.PatternColorIndex = 5; IRange rangeG1H2 = worksheet.Range["G1:H2"]; rangeG1H2.Merge(); rangeG1H2.Interior.Pattern = GrapeCity.Documents.Excel.Pattern.RectangularGradient; (rangeG1H2.Interior.Gradient as IRectangularGradient).ColorStops[0].Color = Color.Red; (rangeG1H2.Interior.Gradient as IRectangularGradient).ColorStops[1].Color = Color.Green; (rangeG1H2.Interior.Gradient as IRectangularGradient).Bottom = 0.2; (rangeG1H2.Interior.Gradient as IRectangularGradient).Right = 0.3; (rangeG1H2.Interior.Gradient as IRectangularGradient).Top = 0.4; (rangeG1H2.Interior.Gradient as IRectangularGradient).Left = 0.5; worksheet.Range["J1:K2"].Merge(); worksheet.Range["J1:K2"].Interior.Color = Color.Green; // Save to a pdf file workbook.Save("SaveRangeFillToPDF.pdf");
' Create a new Workbook Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) Dim rangeA1B2 As IRange = worksheet.Range("A1:B2") rangeA1B2.Merge() rangeA1B2.Interior.Pattern = Pattern.LinearGradient Dim gradientA1B2 = TryCast(rangeA1B2.Interior.Gradient, ILinearGradient) gradientA1B2.ColorStops(0).Color = Color.Red gradientA1B2.ColorStops(1).Color = Color.Yellow gradientA1B2.Degree = 90 Dim rangeE1E2 As IRange = worksheet.Range("D1:E2") rangeE1E2.Merge() rangeE1E2.Interior.Pattern = Pattern.LightDown rangeE1E2.Interior.Color = Color.Pink rangeE1E2.Interior.PatternColorIndex = 5 Dim rangeG1H2 As IRange = worksheet.Range("G1:H2") rangeG1H2.Merge() rangeG1H2.Interior.Pattern = Pattern.RectangularGradient Dim gradientG1H2 = TryCast(rangeG1H2.Interior.Gradient, IRectangularGradient) gradientG1H2.ColorStops(0).Color = Color.Red gradientG1H2.ColorStops(1).Color = Color.Green gradientG1H2.Bottom = 0.2 gradientG1H2.Right = 0.3 gradientG1H2.Top = 0.4 gradientG1H2.Left = 0.5 worksheet.Range("J1:K2").Merge() worksheet.Range("J1:K2").Interior.Color = Color.Green ' save to a pdf file workbook.Save("SaveRangeFillToPDF.pdf")