from aspose.cells import TextAlignmentType, Workbook from aspose.cells.drawing import GradientStyleType from aspose.pydrawing import Color # For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET # The path to the documents directory. dataDir = RunExamples.GetDataDir(".") # Instantiate a new Workbook workbook = Workbook() # Get the first worksheet (default) in the workbook worksheet = workbook.worksheets[0] # Input a value into B3 cell worksheet.cells.get(2, 1).put_value("test") # Get the Style of the cell style = worksheet.cells.get("B3").get_style() # Set Gradient pattern on style.is_gradient = True # Specify two color gradient fill effects style.set_two_color_gradient(Color.from_argb(255, 255, 255), Color.from_argb(79, 129, 189), GradientStyleType.HORIZONTAL, 1) # Set the color of the text in the cell style.font.color = Color.red # Specify horizontal and vertical alignment settings style.horizontal_alignment = TextAlignmentType.CENTER style.vertical_alignment = TextAlignmentType.CENTER # Apply the style to the cell worksheet.cells.get("B3").set_style(style) # Set the third row height in pixels worksheet.cells.set_row_height_pixel(2, 53) # Merge the range of cells (B3:C3) worksheet.cells.merge(2, 1, 1, 2) # Save the Excel file workbook.save(dataDir + "output.xlsx")