Mise à jour de la version 1.2 dans les classeurs pour .NET - Partie III

Dans la troisième partie de cette série de tutoriels, nous poursuivons notre tour d'horizon des changements apportés par Workbooks for .NET v1.2 en examinant la classe ThemeColor" et la façon de modifier les bordures et le remplissage sur le style.

En savoir plus sur Xeed Workbooks pour .NET

Nous poursuivons notre tour d'horizon des changements apportés par Workbooks for .NET v1.2.

Classe ThemeColor

ThemeColor a été ajoutée, qui est utilisée pour représenter un ThèmeLa couleur de l'eau est la même que celle de l'eau de mer.

La classe ThemeColor possède les propriétés suivantes :

  • Tint: the ThemeColor's tint. Values are from -1 (dark) to +1 (light); 0 by default.
  • Type: the ThemeColor's type.

Les types disponibles pour ThemeColor sont actuellement les suivants :

  • Accent1, Accent2, Accent3, Accent4, Accent5, Accent6
  • Background1, Background2
  • FollowedHyperlink, Hyperlink
  • Text1, Text2

Remarque : les propriétés qui couvrent le même élément s'excluent mutuellement. Par exemple, dans l'élément Remplir la définition d'une valeur dans la classe Couleur du thème d'arrière-plan fixera Couleur de fond à null, et vice versa.

Modifier la couleur du thème sur la bordure et la police

ThemeColor a été ajoutée à la propriété Frontière et Police pour spécifier les couleurs du thème. Les classes ThemeColor est de type ThemeColor.

// Setting the ThemeColor
using( var document = Workbook.Load( "testDoc.xlsx" ));
{
	var worksheet = document.Worksheets[ 0 ];

	// Border
	worksheet.Cells[ "B15", "C17" ].Style.Borders[ BorderType.Right ].ThemeColor = new ThemeColor( ThemeColorType.Accent1, -0.5d );

	// Font
	worksheet.Cells[ "C18" ].Style.Font = new Font() { ThemeColor = new ThemeColor( ThemeColorType.Text2, -0.5d ) };

	// save the modifications
	document.Save();
}

Modifier BackgroundThemeColor et PatternThemeColor sur Fill

Deux nouvelles propriétés ont été ajoutées au Remplir classe :

  • BackgroundThemeColor: used for filling the background of a Cell, Row, Column or range; null by default.
  • PatternThemeColor: used for filling a Cell, Row, Column or range; null by default. The Cell, Row, Column or range are filled based on the PatternStyle property.

Les deux Couleur du thème d'arrière-plan et MotifThemeColor sont de type ThemeColor.

// Setting BackgroundThemeColor and PatternThemeColor
using( var document = Workbook.Load( "testDoc.xlsx" ));
{
	var worksheet = document.Worksheets[ 0 ];

	// Fill
	worksheet.Cells[ "C12" ].Style.Fill = new Fill() { PatternStyle = FillPattern.ThinDiagonalCrosshatch, BackgroundThemeColor = new ThemeColor( ThemeColorType.Background1, -0.5d ), PatternThemeColor = new ThemeColor( ThemeColorType.Accent4, -0.5d ) };

	// save the modifications
	document.Save();
}

Modifier la couleur du TabThemeColor sur la feuille de calcul

Couleur du thème de l'onglet a été ajoutée à la propriété Feuille de travail pour spécifier la couleur du thème des onglets de la feuille de calcul ; null par défaut. La classe Couleur du thème de l'onglet est de type ThemeColor.

// Setting the ThemeColor
using( var document = Workbook.Load( "testDoc.xlsx" ));
{
	var worksheet = document.Worksheets[ 0 ];
	worksheet.TabThemeColor = new ThemeColor( ThemeColorType.Accent5, -0.5d );

	// save the modifications
	document.Save();
}

Modifier les bordures sur le style

Frontières a été ajoutée à la propriété Style pour personnaliser l'aspect des bordures. La classe Frontières est un Collection de frontières objet de type.

La classe BorderCollection possède les méthodes suivantes :

  • SetDiagonals: Sets the DiagonalUp and DiagonalDown borders using the same lineStyle and color.
  • SetInside: Sets the Horizontal and Vertical Borders using the same lineStyle and color.
  • SetOutline: Sets the Left, Right, Top and Bottom Borders using the same lineStyle and color.
  • SetThemeDiagonals: Sets the DiagonalUp and DiagonalDown Borders using the same lineStyle and themeColor.
  • SetThemeInside: Sets the Horizontal and Vertical Borders using the same lineStyle and themeColor.
  • SetThemeOutline: Sets the Left, Right, Top and Bottom Borders using the same lineStyle and themeColor.
// Setting the Borders on a Style
using( var document = Workbook.Load( "testDoc.xlsx" ));
{
	var worksheet = document.Worksheets[ 0 ];

	// Specify the borders
	var cellRange = worksheet.Cells[ "B15", "C17" ];
	cellRange.Style.Borders.SetInside( LineStyle.Medium, Color.DarkGreen );
	cellRange.Style.Borders.SetOutline( LineStyle.Medium, Color.DarkGreen );

	// save the modifications
	document.Save();
}

Modifier le remplissage sur le style

Remplir a été ajoutée à la propriété Style pour personnaliser l'aspect du remplissage. La classe Remplir est un Remplir objet de type.

La classe Fill possède les propriétés suivantes :

  • BackgroundColor: the Color used for filling the background of a Cell, Row, Column or range; null by default.
  • BackgroundThemeColor: the ThemeColor used for filling the background of a Cell, Row, Column or range; null by default.
  • PatternColor: the Color of the pattern used for filling a Cell, Row, Column or range; null by default. This will be based on the PatternStyle property.
  • PatternStyle: the Style of the pattern used for filling a Cell, Row, Column or range; FillPattern.None by default. These will be filled based on the PatternColor property.
  • PatternThemeColor: the ThemeColor of the pattern used for filling a Cell, Row, Column or range; null by default. The Cell, Row, Column or range are filled based on the PatternStyle property.
// Setting the Fill on a Style
using( var document = Workbook.Load( "testDoc.xlsx" ));
{
	var worksheet = document.Worksheets[ 0 ];

	worksheet.Cells[ "C12" ].Style.Fill = new Fill() { PatternStyle = FillPattern.ThinDiagonalCrosshatch, PatternColor = Color.Green, BackgroundColor = Color.Blue };

	// save the modifications
	document.Save();
}

Plus d'informations dans la quatrième partie, restez à l'écoute !

Pour plus d'informations, veuillez vous référer à la la documentation.