Applicera stil på en rad eller kolumn

Applicera stil på en kolumn

För att tillämpa en anpassad stil på en kolumn med hjälp av Aspose.Cells.GridDesktop, följ följande steg:

  • Kom åt något önskat Kalkylblad
  • Öppna en Kolumn på vilken vi vill applicera en Stil
  • Hämta Stil för Kolumnen
  • Ange Stil-egenskaper enligt dina anpassade behov
  • Slutligen, ange Stilen för Kolumnen med den uppdaterade

Det finns många användbara egenskaper och metoder som erbjuds av Stil-objektet som kan användas av utvecklare för att anpassa stilen enligt deras krav.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Accessing the worksheet of the Grid that is currently active
Worksheet sheet = gridDesktop1.GetActiveWorksheet();
// Accessing the first column of the worksheet
Aspose.Cells.GridDesktop.Data.GridColumn column = sheet.Columns[0];
// Adding sample value to sheet cell
GridCell cell = sheet.Cells["a1"];
cell.SetCellValue("Aspose");
// Getting the Style object for the column
Style style = column.GetStyle();
// Setting Style properties i.e. border, alignment color etc.
style.SetBorderLine(BorderType.Right, BorderLineType.Thick);
style.SetBorderColor(BorderType.Right, Color.Blue);
style.HAlignment = HorizontalAlignmentType.Centred;
// Setting the style of the column with the customized Style object
column.SetStyle(style);

Applicera stil på en rad

För att tillämpa en anpassad stil på en rad med hjälp av Aspose.Cells.GridDesktop, följ följande steg:

  • Kom åt något önskat Kalkylblad
  • Öppna en Rad på vilken vi vill applicera en Stil
  • Hämta Stil för Radet
  • Ange Stil-egenskaper enligt dina anpassade behov
  • Slutligen, ange Stilen för Radet med den uppdaterade

Det finns många användbara egenskaper och metoder som erbjuds av Stil-objektet som kan användas av utvecklare för att anpassa stilen enligt deras krav.

 // Accessing the worksheet of the Grid that is currently active

Worksheet sheet = gridDesktop1.GetActiveWorksheet();

// Accessing the first row of the worksheet

Aspose.Cells.GridDesktop.Data.GridRow row = sheet.Rows[0];

// Getting the Style object for the row

Style style = row.GetStyle();

// Setting Style properties i.e. border, color, alignment, background color etc.

style.SetBorderLine(BorderType.Right, BorderLineType.Thick);

style.SetBorderColor(BorderType.Right, Color.Blue);

style.HAlignment = HorizontalAlignmentType.Centred;

style.Color = Color.Yellow;

// Setting the style of the row with the customized Style object

row.SetStyle(style);