Introduction
  Welcome
  The Web Reporting Solution
  What is ExcelWriter?
  Features and Benefits
  New in This Version  V4
  Requirements
  Edition Differences
  Frequently Asked Questions
  Troubleshooting

Quick Start
  Creating Your First Spreadsheet
  Adding a Formula
  Adding Formatting
  Importing from a Database

Features In Depth
  Addressing Cells
  Setting Values
  Output Options
  Adding Charts
  Reading an Existing Spreadsheet
  Modifying an Existing Spreadsheet
  The Range Object
  Template Spreadsheets
  How to Use Templates
  ExcelApp.Open vs. ExcelTemplate
  Using ExcelTemplate with PivotTables
  Templates and Charts
  Reliable Spreadsheet Download  V4
  Page Setup
  Formatting Headers & Footers
  Protecting your Worksheet
  Multilingual Support  V4
  XML Import

HotCell Technology  V4
  What is HotCell Technology?
  Upload Example
  Advanced POST Example
  Advanced Upload Example

Programmer's Reference
  Object Model
      ExcelTemplate Object
      ExcelApplication Object
         3DProperties Object
         Area Object
         Axis Object
         Cells Object
         Cell Object
         Charts Object
         Chart Object
         ChartFrame Object
         Font Object
         Line Object
         PageSetup Object
         Pictures Object
         Picture Object
         Range Object
         SeriesCollection Object
         Series Object
         Style Object
         Worksheets Object
         Worksheet Object
  Formula Functions
  Formula Calculation Operators
  Formatting Codes
  Chart Codes

Installation
  Quick Installation
  Configuring IIS
  Security Considerations

External Links
  ExcelWriter Home Page
  Technical Support
  ExcelWriter Demos
  SoftArtisans Home Page
  E-mail General Questions
  E-mail Technical Support
  Legal Information

Object Model ExcelApplication ExcelTemplate Worksheets Worksheet Cells Cell Range Style Font Charts
Chart SeriesCollection Series 3DProperties Axis ChartFrame Line Area Pictures Picture PageSetup


The Style Object (SAStyle)

To define a style, first set a Style object, and assign values to any or all of its properties, for example,

	Dim mystyle As SAStyle
	Set mystyle = xlw.CreateStyle
	mystyle.Font.Name = "Arial"
	mystyle.Font.Bold = True
	mystyle.HorizontalAlignment = sahaRight
	

Then, assign your style to an individual cell, for example,

	ws.cells("A1").style = mystyle
	

Alternatively, you could assign your style to a pre-defined range object, for example, one that encompasses two rows and spans 5 columns:

	Set Rng1 = Ws.Cells.Range(3,3,2,5)
	Rng1.style = mystyle
	

Then, if you wish to supplement the style for a single cell (for example, one that is contained within "Rng1") with additional formatting properties, use the Cell.Format property as follows:

	Ws.Cells(3,5).Format.WrapText= True
	

Style Methods and Properties

Style Methods and Properties
BackgroundColor

Sets or retrieves a style's background color. Use RGB values to assign colors, as in the following example.

	Set mystyle = xlw.CreateStyle
	mystyle.BackgroundColor = rgb(0,0,255) '--- blue
	ws.cells("a1").value = "Blue Cell"
	ws.cells("a1").style = mystyle
	

Top

BorderColor

Sets or retrieves a cell's border color. Use RGB values to assign colors, as in the following example.

The property could take an optional parameter, such as BorderColor(sabpLeft), by specifying the border index defined as:

sabpLeft1sabpDiagonalDown16
sabpRight2sabpDiagonalUp32
sabpTop4sabpDiagonalBoth48
sabpBottom8sabpAll63
sabpOutline (default)15
	Set mystyle = xlw.CreateStyle
	mystyle.BorderColor = rgb(0,0,255)
	ws.cells("a1").value = "Blue border"
	ws.cells("a1").style = mystyle
	

Top

BorderLineStyle

Sets or retrieves a cell's border style. ExcelWriter supports the following thirteen border styles.

sadgThin1sadgMediumDashed8
sadgMedium2sadgDashDot9
sadgDashed3sadgMediumDashDot10
sadgDotted4sadgDashDotDot11
sadgThick5sadgMediumDashDotDot12
sadgDouble6sadgSlantedDashDot13
sadgHair7

The property could take an optional parameter, such as BorderLineSytle(sabpLeft), by specifying the border index defined as:

sabpLeft1sabpDiagonalDown16
sabpRight2sabpDiagonalUp32
sabpTop4sabpDiagonalBoth48
sabpBottom8sabpAll63
sabpOutline (default)15

Example:

	Set mystyle = xlw.CreateStyle
	mystyle.BorderLineStyle = 3
	ws.cells("a1").value = "Dashed border"
	ws.cells("a1").style = mystyle
	

Top

ForegroundColor

Sets or retrieves a style's foreground color. A foreground color is visible when a pattern is assigned to a cell. Use RGB values to assign colors, as in the following example.

	Set mystyle = xlw.CreateStyle
	mystyle.Pattern = 8   '--- diagonal stripe
	mystyle.ForegroundColor = rgb(255,0,0)   '--- red
	ws.cells("a1").value = "Red stripe"
	ws.cells("a1").style = mystyle
	

Top

Font

Use the Font property to set a font for your style. Font contains several properties, each of which define an aspect your font. These properties are Name, Size, Bold, Italic, Underline, Strikethrough, Weight, Charset, Subscript, Superscript, and Color. To define your style's font as 10pt italic Tahoma, use,

	Set mystyle = xlw.CreateStyle
	mystyle.Font.Name = "Tahoma"
	mystyle.Font.Size = 10
	mystyle.Font.Italic = true
	

Top

Hidden*

Hides cell formulas. The Hidden property is set to False by default. To hide formulas, use

	mystyle.hidden = true
	

Hiding cells has no effect unless the worksheet is protected. To protect a worksheet,

  1. Open the worksheet in Microsoft Excel.
  2. Open the Tools menu, and select Protection -> Protect Sheet.

Top

HorizontalAlignment

Determines the horizontal alignment of the text in your spreadsheet. HorizontalAlignment has six possible values. You can assign a value by its name or code. The HorizontalAlignment value names and codes are,

sahaUnspecified-1
sahaGeneral0
sahaLeft1
sahaCenter2
sahaRight3
sahaFill4
sahaJustify5
sahaCenterAcross6

To center text within your cells, use,

	mystyle.HorizontalAlignment = haCenter
	

Top

Locked*

Determines whether a cell can be modified or not. The Locked property is set to True by default. To unlock cells, use,

	mystyle.locked = false
	

Locking cells has no effect unless the worksheet is protected. To protect a worksheet,

  1. Open the worksheet in Microsoft Excel.
  2. Open the Tools menu, and select Protection -> Protect Sheet.
Or, use Worksheet.WriteProtect.

Top

Name*

Sets or returns a style name. The following example demonstrates setting a style name.

	mystyle.name = "mystyle"
	

Top

Number

Sets the display format of numbers and dates. For a complete list of Number codes, see Formatting Codes. The following example demonstrates assigning the percentage format to a style.

	mystyle.number = 10
	

Top

Orientation*

Determines text orientation. Orientation has four possible values. You can assign a value by its name or code. The Orientation value names and codes are,

saoriUnspecified-1Value not specified
saoriNoRotation0Default value
saoriTopToBottom1Displays text from top to bottom of the cell
saoriCounterClockWise2Rotates text 90 degrees to the right
saoriClockWise3Rotates text 90 degrees to the left

To display text from top to bottom, use,

	mystyle.orientation = TopToBottom
	

Top

Pattern

Sets or retrieves a cell background pattern. ExcelWriter supports the following 18 patterns.

saptrnSolid1saptrnThickDiagonalCrosshatch10
saptrn50Gray2saptrnThinHorizontalStripe11
saptrn75Gray3saptrnThinVerticalStripe12
saptrn25Gray4saptrnThinReverseDiagonalStripe13
saptrnHorizontalStripe5saptrnThinDiagonalStripe14
saptrnVerticalStripe6saptrnThinHorizontalCrosshatch15
saptrnReverseDiagonalStripe7saptrnThinDiagonalCrosshatch16
saptrnDiagonalStripe8saptrn12Gray17
saptrnDiagonalCrosshatch9saptrn6Gray18

Example:

	Set mystyle = xlw.CreateStyle
	mystyle.Pattern = 9  
	ws.cells("a1").value = "Diagonal Crosshatch"
	ws.cells("a1").style = mystyle
	

Top

VerticalAlignment

Determines the vertical alignment of the text in your spreadsheet. VerticalAlignment has four possible values. You can assign a value by its name or code. The VerticalAlignment value names and codes are,

savaUnspecified-1Alignment is not specified
savaTop0Aligns text with the top of cells
savaCenter1Vertically centers text within cells
savaBottom2Aligns text with the bottom of cells (Default value)
savaJustify3Vertically justifies text within cells
To align text with the top of cells, use,
	mystyle.VerticalAlignment = vaTop
	

Top

WrapText

Use the WrapText property to wrap text within cells. WrapText may be either True or False. WrapText is False by default. To set WrapText to True, use,

	mystyle.wraptext = true
	

Top

*These features are not available in ExcelWriterSE, ExcelWriterLE, or ExcelWriterFree.


Object Model ExcelApplication ExcelTemplate Worksheets Worksheet Cells Cell Range Style Font Charts
Chart SeriesCollection Series 3DProperties Axis ChartFrame Line Area Pictures Picture PageSetup


Copyright © 2003, SoftArtisans, Inc.