Actualización de la versión 1.2 en Workbooks for .NET - Parte III

En la tercera parte de esta serie de tutoriales, continuamos nuestra visión general de los cambios en Workbooks for .NET v1.2 examinando la clase ThemeColor" y cómo modificar Borde y Relleno en Estilo

Más información Cuadernos Xeed para .NET

Continuamos nuestra visión general de los cambios en Workbooks for .NET v1.2.

Clase ThemeColor

TemaColor que se utiliza para representar una clase Temacolor.

La clase ThemeColor tiene las siguientes propiedades:

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

Los tipos disponibles para ThemeColor actualmente incluyen:

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

Nota: las propiedades que cubren el mismo elemento se excluyen mutuamente. Por ejemplo, en el elemento Rellene estableciendo un valor en BackgroundThemeColor establecerá Color de fondo a nulo, y viceversa.

Modificar ThemeColor en Borde y Fuente

TemaColor se ha añadido a la propiedad Frontera y Fuente para especificar los colores del Tema. La página TemaColor es de tipo TemaColor.

// 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();
}

Modificar BackgroundThemeColor y PatternThemeColor en Fill

Se han añadido dos nuevas propiedades a Rellene clase:

  • 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.

Tanto el BackgroundThemeColor y PatrónTemaColor son del tipo TemaColor.

// 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();
}

Modificar TabThemeColor en la hoja de cálculo

TabThemeColor se ha añadido a la propiedad Hoja de trabajo para especificar el color del tema de las pestañas de la hoja de cálculo; nulo por defecto. La clase TabThemeColor es de tipo TemaColor.

// 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();
}

Modificar los bordes del estilo

Fronteras se ha añadido la propiedad Estilo para personalizar el aspecto de los bordes. La página Fronteras es una propiedad Colección de bordes tipo objeto.

La clase BorderCollection tiene los siguientes métodos:

  • 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();
}

Modificar el relleno en el estilo

Rellene se ha añadido la propiedad Estilo para personalizar el aspecto del relleno. La página Rellene es una propiedad Rellene tipo objeto.

La clase Fill tiene las siguientes propiedades:

  • 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();
}

Más información en la Parte IV, ¡siga atento!

Para más información, consulte el documentación.