Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Description

Excerpt

ExcelWriter has three style types: CellStyle, GlobalStyle, and NamedStyle.

Signature
C#
C#
 public class Style
{signature}{signature:
}
Signature
vb.net
vb.net
Public Class Style
{signature}
{remarks}
All three types derive from the [Style|Style] class, and {{NamedStyle}} derives from {{GlobalStyle}}.

You cannot create a CellStyle, only manipulate existing ones as part of the objects they apply to.  To create a {{GlobalStyle}}, use [
Remarks

All three types derive from the Style class, and NamedStyle derives from GlobalStyle.

You cannot create a CellStyle, only manipulate existing ones as part of the objects they apply to. To create a GlobalStyle, use Workbook.CreateStyle()

|Workbook

.

CreateStyle()].

To

create

a

{{

NamedStyle

}}

,

use

[

Workbook.CreateNamedStyle()

|Workbook

.

CreateNamedStyle(String)].

To

get

a

{{

NamedStyle

}}

from

an

existing

document,

use

[

Workbook.GetNamedStyle()

|Workbook.GetNamedStyle(String)]. {remarks} {example}{code:csharp|title=C#}

.

Example
Code Block
csharp
csharp
titleC#


          //--- Open existing spreadsheet
          ExcelApplication xla = new ExcelApplication();
          Workbook wb = xla.Open(@"C:\MySpreadsheet.xls");

          //--- Create GlobalStyle
          Style global = wb.CreateStyle();

          //--- Create NamedStyle
          Style newNamed = wb.CreateNamedStyle("MyStyle");

          //--- Get NamedStyle
          Style existingNamed = wb.GetNamedStyle("ExistingStyle");
        
{code} {code:vbnet|title=
Code Block
vbnet
vbnet
titlevb.net
}


          '--- Open existing spreadsheet
          Dim xla As New ExcelApplication()
          Dim wb As Workbook = xla.Open("C:\MySpreadsheet")

          '--- Create GlobalStyle
          Dim global As Style = wb.CreateStyle()

          '--- Create NamedStyle
          Dim newNamed As Style = wb.CreateNamedStyle("MyStyle")

          '--- Get NamedStyle
          Dim existingNamed As Style = wb.GetNamedStyle("ExistingStyle")
        
{code} {example} {properties} ||Name||Description|| |[BackgroundColor|Style.BackgroundColor]|{excerpt-include:Style.BackgroundColor|nopanel=true}| |[Border|Style.Border]|{excerpt-include:Style.Border|nopanel=true}| |[CellLocked|Style.CellLocked]|{excerpt-include:Style.CellLocked|nopanel=true}| |[Font|Style.Font]|{excerpt-include:Style.Font|nopanel=true}| |[ForegroundColor|Style.ForegroundColor]|{excerpt-include:Style.ForegroundColor|nopanel=true}| |[HideFormulas|Style.HideFormulas]|{excerpt-include:Style.HideFormulas|nopanel=true}| |[HorizontalAlignment|Style.HorizontalAlignment]|{excerpt-include:Style.HorizontalAlignment|nopanel=true}| |[IndentLevel|Style.IndentLevel]|{excerpt-include:Style.IndentLevel|nopanel=true}| |[JustifyDistributed|Style.JustifyDistributed]|{excerpt-include:Style.JustifyDistributed|nopanel=true}| |[NumberFormat|Style.NumberFormat]|{excerpt-include:Style.NumberFormat|nopanel=true}| |[Orientation|Style.Orientation]|{excerpt-include:Style.Orientation|nopanel=true}| |[Pattern|Style.Pattern]|{excerpt-include:Style.Pattern|nopanel=true}| |[ShrinkToFit|Style.ShrinkToFit]|{excerpt-include:Style.ShrinkToFit|nopanel=true}| |[TextDirection|Style.TextDirection]|{excerpt-include:Style.TextDirection|nopanel=true}| |[VerticalAlignment|Style.VerticalAlignment]|{excerpt-include:Style.VerticalAlignment|nopanel=true}| |[WrapText|Style.WrapText]|{excerpt-include:Style.WrapText|nopanel=true}| {classes} ||Name||Description|| |[ColumnInsertBehavior|Style.ColumnInsertBehavior]|{excerpt-include:Style.ColumnInsertBehavior|nopanel=true}| |[HAlign|Style.HAlign]|{excerpt-include:Style.HAlign|nopanel=true}| |[RowInsertBehavior|Style.RowInsertBehavior]|{excerpt-include:Style.RowInsertBehavior|nopanel=true}| |[TextDir|Style.TextDir]|{excerpt-include:Style.TextDir|nopanel=true}| |[VAlign|Style.VAlign]|{excerpt-include:Style.VAlign|nopanel=true}|
Properties

Name

Description

BackgroundColor

Excerpt Include
Style.BackgroundColor
Style.BackgroundColor
nopaneltrue

Border

Excerpt Include
Style.Border
Style.Border
nopaneltrue

CellLocked

Excerpt Include
Style.CellLocked
Style.CellLocked
nopaneltrue

Font

Excerpt Include
Style.Font
Style.Font
nopaneltrue

ForegroundColor

Excerpt Include
Style.ForegroundColor
Style.ForegroundColor
nopaneltrue

HideFormulas

Excerpt Include
Style.HideFormulas
Style.HideFormulas
nopaneltrue

HorizontalAlignment

Excerpt Include
Style.HorizontalAlignment
Style.HorizontalAlignment
nopaneltrue

IndentLevel

Excerpt Include
Style.IndentLevel
Style.IndentLevel
nopaneltrue

JustifyDistributed

Excerpt Include
Style.JustifyDistributed
Style.JustifyDistributed
nopaneltrue

NumberFormat

Excerpt Include
Style.NumberFormat
Style.NumberFormat
nopaneltrue

Orientation

Excerpt Include
Style.Orientation
Style.Orientation
nopaneltrue

Pattern

Excerpt Include
Style.Pattern
Style.Pattern
nopaneltrue

ShrinkToFit

Excerpt Include
Style.ShrinkToFit
Style.ShrinkToFit
nopaneltrue

TextDirection

Excerpt Include
Style.TextDirection
Style.TextDirection
nopaneltrue

VerticalAlignment

Excerpt Include
Style.VerticalAlignment
Style.VerticalAlignment
nopaneltrue

WrapText

Excerpt Include
Style.WrapText
Style.WrapText
nopaneltrue
Classes

Name

Description

ColumnInsertBehavior

Excerpt Include
Style.ColumnInsertBehavior
Style.ColumnInsertBehavior
nopaneltrue

HAlign

Excerpt Include
Style.HAlign
Style.HAlign
nopaneltrue

RowInsertBehavior

Excerpt Include
Style.RowInsertBehavior
Style.RowInsertBehavior
nopaneltrue

TextDir

Excerpt Include
Style.TextDir
Style.TextDir
nopaneltrue

VAlign

Excerpt Include
Style.VAlign
Style.VAlign
nopaneltrue