Quick_reference_guide Xlslib Ref Guide

User Manual: Pdf

Open the PDF directly: View PDF PDF.
Page Count: 15

xlsLib
Copyright 2004 - Yeico S.A. de C.V.
A library for dynamically generating Excel(TM) spreadsheets
PHP Extension's
Quick Reference Guide
Yeico S.A. de C.V.
Instantiation:
Usage:
Operation Description
Stroke string Name none Sends the spreadsheet hold by the workbook object to
the client. The file gets the name set by the 'Name'
argument.
Dump string Name none Writes the spreadsheet hold by the workbook to a file
'Name'. Only recommended when the script is called
from the Command Line.
Disposition constant {STK_INLINE,
STK_ATTACHMENT}
none
Defines the way the file will be managed by the client (if
it is supported)'. i.e. STK_INLINE will automatically
open the default application.
sheet string NameSheet worksheet object Creates a worksheet in the current workbook assigning
the name passed as argument.
xformat none xf_t object Creates a customizable extended format object that
can be passed as an arguments to any cell element. All
format objects used by the workbook's elements have
to be generated with this operation.
font string Font name font_t object Creates a customizable font object that can be passed
as an arguments to a format object element. All font
objects used by the workbook's elements have to be
generated with this operation.
Argument(s) Return Value
Workbook Operations
workbook is the base object of the library. All other objects are generated in it, and it controls the streaming of the generated file.
$wb_obj = new workbook;
$retval = wb_obj->operation([$arg1[,$arg2[, ...]]],;
Instantiation:
Usage:
Operation Description
integer
unsigned16
row
integer
unsigned16
col
xf_t object
integer
unsigned16
row
integer
unsigned16
col
string label_text
xf_t object
integer
unsigned16
row
integer
unsigned16
col
double number
constant
format_number_t (See the table of
values in the appendixes)
xf_t object
integer
unsigned16
row_num
integer
unsigned16
height
integer
unsigned16
col_num
integer
unsigned16
width
integer
unsigned16
col_1
integer
unsigned16
row_1
integer
unsigned16
col_2
integer
unsigned16
row_2
integer
unsigned16
col_1
integer
unsigned16
row_1
integer
unsigned16
col_2
integer
unsigned16
row_2
rangegroup range object Returns an object that handles a group of cells given
by the range defined with the arguments. This range
object can be seen and modified as a cell unit and all
format setting (including borders) will apply to all of the
cells inside the range.
merge none Merges the given range of cells in to one. The format
used to display the cell's valueis the top-left most of the
range.
colwidth none
Sets the width size of the 'col_num' column in character-
widths.
rowheight none Sets the height size of the 'row_num' row in points.
number cell_t object Adds a number cell to the current worksheet at the
(row,col) position usinga format_number_t constant to
format number's display
Adds a blank cell to the current worksheet at the
(row,col) position.
label cell_t object Adds a label cell to the current worksheet at the
(row,col) position using'label_text' as the text of the
label. NOTE: Due format specifications, text inside a
label cannot be longer than 255 chars; if a longer input
is used, the text is truncated with...
Argument(s) Return Value
blank cell_t object
Worksheet Operations
The worksheet object handles a logical sheet-unit. It is the source of cell-objects , and it controls general cell sizing and
merging.
$ws_obj = $wb_obj->worksheet("Name");
$retval = $ws_obj->operation([$arg1[,$arg2[, ...]]],;
Usage:
Operation Description
font font_t object none It assigns a font object to the cell. The font object full-
defines the font to be used by the cell. Its use is
recommended for defining the same font style to
multiple cells. For discrete font settings, use of the
following operations are recommended.
format format_number_t constant none It assigns a formatting number to the cell (it will be
used only if the cell contains a number). See the
appendixes for a detailed list of format constants
halign halign_option_t constant (see the appendixes for
a detailed constant list)
none Sets the horizontal alignment of the the text inside the
cell.
valign valign_option_t constant (see the appendixes for
a detailed constant list)
none Sets the vertical alignment of the the text inside the
cell.
orientation txtori_option_t constant (see the appendixes for
a detailed constant list)
none Sets the text orientation of the cell.
fillfgcolor color_name_t constant (see the appendixes for
a detailed color constant list)
none Sets the foreground color of the cell.
fillbgcolor color_name_t constant (see the appendixes for
a detailed color constant list)
none Sets the background color of the cell.
fillstyle color_name_t constant (see the appendixes for
a detailed fill-pattern constant list)
none Sets the fill-pattern of the cell.Back/fore-ground colors
are related to these patterns.
wrap boolean 1/0 none
If set, text inside the cell is wrapped in the current cell's
size.
border_side_t constant
border_style_t constant
color_name_t constant
locked boolean 1/0 none If set, the cell is locked. Currently it has no effect,
since worksheet protection is not implemented yet.
hidden boolean 1/0 none If set, the cell is hidden. Currently it has no effect,
since worksheet protection is not implemented yet.
fontname string name none Sets font's name to be used by the cell. You can pass
any string, but in in order to have any effect, is has to
be the name of a font supported by your *.xls file
reader. When a non supported font is passed, the
behavior when opening the file will depe...
fontheight number (unsigned16) fntheight none Sets the height of the cell's font. The height is set in
1/20th of point: i.e fontheight=200 sets the font's height
to 10.
fontbold boldness_option_t constant none Sets the boldness of the cell's font according to the
font_boldness_t constant. See the appendixes for a
detailed list of available constants.
fontunderline underline_option_t constant none Sets the underline style of the cell's font according to
the font_underline_t constant. See the appendixes for
a detailed list of available constants.
fontscript script_option_t {SCRIPT_NONE,
SCRIPT_SUPER,
SCRIPT_SUB}
none Sets the script style (super/under-script) of the cell's
font according to the font_underline_t constant.
fontcolor color_name_t constant none Sets the color of the cell's font according to the
font_underline_t constant See the appendixes for a
detailed list of available color constants.
fontitalic boolean 0/1 none If set, the cell's font is shown italic shaped.
fontstrikeout boolean 0/1 none If set, the cell's font is shown strike-out shaped.
fontshadow boolean 0/1 none If set, the cell's font is shown with shadow (if
supported).
GetRow none integer
unsigned16
Returns the cell's row number (0-index based) of the
current cell.
GetCol none integer
unsigned16
Returns the cell's column number (0-index based) of
the current cell.
SetXF xf_t object none Sets the cell's format to the one passed as argument.
The xf_t object has to be previously generated with the
wb_obj->xformat()
GetXF none xf_t object Gets the format object assigned to the cell.
Cell Font Style
Other Operations
Argument(s) Return Value
Cell Formatting
borderstyle none Sets the border selected by border_side_t to the
border_style_t style andcolor_name_t color. All
standard styles and colors are supported. See the
appendixes for a full list of available constants.
Cell Operations
Any cell-type (blank, label, number) falls into this category and these operations can be applied to them. Standard format
and font manipulation can be performed on any cell.
$cell_obj = $wb_obj-><blank|label|number>(args);
$retval = cell_obj->operation([$arg1[,$arg2[, ...]]],;
Instantiation:
Usage:
Operation Description
cellcolor color_name_t constant none Sets the background color of each cell inside the
range. This is a wrapper function to an operation that
involves changing the fill-pattern and color of each
cell.
Argument(s) Return Value
Range Operations
A range can be seen as a cell. The same operations of a cell apply to a range. Note that for border settings, borders are
set to each member of the range.
Besides cell operations, the following table shows some extra operations, specific to range objects.
$range_obj = $wb_obj->ramge(row1, col1, row2, col2);
$retval = range_obj->operation([$arg1[,$arg2[, ...]]],;
Instantiation:
Usage:
Operation Description
SetFont font_t object none Sets the font attached to the format. The font_t object
has to be generated with the workbook's font
operation.
GetFont none font_t object Retrieves the font attached to the format.
GetFormat none format_num
ber_t
constant Sets the format for display numbers in the cell. See
the appendixes for a detailed list of choices.
SetFormat format_number_t constant none Gets the format number of the format object
SetHalign halign_option_t constant none Sets the text horizontal alignment of the cell. See the
appendixes for a detailed list of available options.
SetValign valign_option_t constant none Sets the text vertical alignment of the cell. See the
appendixes for a detailed list of available options.
SetTxtOrientation txtori_option_t constant none Sets the text orientation of the cell. See the
appendixes for a detailed list of available options.
SetFillFGColor color_name_t constant none Sets the filling pattern foreground color. See the
appendixes for a detailed list of available options.
SetFillBGColor color_name_t constant none Sets the filling pattern background color. See the
appendixes for a detailed list of available options.
SetFillStyle fill_option_t constant none
Sets the cell's fill pattern style. See the appendixes for
a detailed list of available options.
SetWrap boolean 0/1 none If set, the cell that has this format will wrap its text
inside to the boundaries of the cell.
border_side_t constant
border_style_t constant
color_name_t constant
SetLocked boolean 0/1 none Set the cell as locked. Currently protected workbooks
are not supported. so there is no visible effect with
this operation.
SetHidden boolean 0/1 none
Set the cell as Hidden. Currently protected workbooks
are not supported. so there is no visible effect with
this operation.
Sets the border shape (border_style_t) and color
(color_name_t) of the specified side of the cell
(border_side_t).See the appendixes for a detailed list
of available options.
Argument(s) Return Value
SetBorderStyle none
Format Object Operations
An xf_t object can be discretely set using these low level operations.Changing format's settings to an already used
format object using these operations will affect to all cells currently using the format.
$xf_obj = $wb_obj->xformat();
$retval = $xf_obj->operation([$arg1[,$arg2[, ...]]],;
Instantiation:
Usage:
Operation Description
SetName string name none Sets the name of the font (i.e. "Arial"). You can use
any string and the effect will depend on the *.xls file
reader, most readers will use a default font if the
name is not found to be an installed font.
SetHeight integer
unsigned16
fntheight none Sets the height of the font in 1/20th of point units
SetBoldStyle boldness_option_t constant none Sets the boldness of the font. See the available
constant choices in the appendixes.
SetUnderlineStyle underline_option_t constant none Sets the underline style of the font. See the available
constant choices in the appendixes.
SetScriptStyle script_option_t constant none Sets the script style of the font. See the available
constant choices in the appendixes.
SetColor color_name_t constant none Sets the color of the font. See the available constant
choices in the appendixes.
SetStrikeout boolean 0/1 none If set, the font is strike-out.
SetShadow boolean 0/1 none If set, the font is shadowed.
Argument(s) Return Value
Font Object Operations
A font_t object can be discretely set using these low level operations.Changing font's settings to an already used font
object using these operations will affect to all cells currently using the font.
$xf_obj = $wb_obj->xformat();
$retval = $xf_obj->operation([$arg1[,$arg2[, ...]]],;
Value Constant Description
0 COLOR_BLACK black
1 COLOR_DARK_RED dark red
2 COLOR_RED red
3 COLOR_FUCSIA fucsia
4 COLOR_COMBINED01 combined 01
5 COLOR_COMBINED02 combined 02
6 COLOR_COMBINED03 combined 03
7 COLOR_COMBINED04 combined 04
8 COLOR_COMBINED05 combined 05
9 COLOR_COMBINED06 combined 06
10 COLOR_OLIVE olive
11 COLOR_DARK_YELLOW dark yellow
12 COLOR_COMBINED07 combined 07
13 COLOR_YELLOW yellow
14 COLOR_LIGHT_YELLOW light yellow
15 COLOR_DARK_GREEN dark green
16 COLOR_GREEN green
17 COLOR_COMBINED08 combined 08
18 COLOR_LIVING_GREEN living green
19 COLOR_LIGHT_GREEN light green
20 COLOR_COMBINED09 combined 09
21 COLOR_BLUE_GREEN blue green
22 COLOR_AQUAMARINA aquamarine
23 COLOR_TURQOISE turquoise
24 COLOR_COMBINED10 combined 10
25 COLOR_DARK_BLUE dark blue
26 COLOR_BLUE blue
27 COLOR_LIGHT_BLUE blue
28 COLOR_SKY_BLUE sky blue
29 COLOR_COMBINED11 combined 11
30 COLOR_INDIGO indigo
31 COLOR_BLUE_GRAY blue gray
32 COLOR_VIOLET violet
33 COLOR_PLUM plum
34 COLOR_LAVANDER lavender
35 COLOR_COMBINED12 combined 12
36 COLOR_GRAY50 gray50
37 COLOR_GRAY40 gray40
38 COLOR_GRAY25 gray25
39 COLOR_WHITE white
Appendix A. Color Constants.
Color constants Either the numeric value or the constant itself can
be used in operation calls.
color_name_t
Value Constant Description
0 BORDER_NONE none
1 BORDER_THIN thin
2 BORDER_MEDIUM medium
3 BORDER_DASHED dashed
4 BORDER_DOTTED dotted
5 BORDER_THICK thick
6 BORDER_DOUBLE double
7 BORDER_HAIR hair
Value Constant Description
0 BORDER_BOTTOM Bottom side
1 BORDER_TOP Top side
2 BORDER_LEFT Left side
3 BORDER_RIGHT Right side
Appendix B. Border constants
Either the numeric value or the constant itself can be used in
operation calls.
border_style_t
border_side_t
Value Constant Description Sample
0 FILL_NONE No fill
1 FILL_SOLID Solid
2 FILL_ATEN75 75% attenuation
3 FILL_ATEN50 50% attenuation
4 FILL_ATEN25 25% attenuation
5 FILL_ATEN12 12% attenuation
6 FILL_ATEN06 6% attenuation
7 FILL_HORIZ_LIN Horizontal lines
8 FILL_VERTICAL_LIN Vertical lines
9 FILL_DIAG Diagonal lines
10 FILL_INV_DIAG Inverted diagonal lines
11 FILL_INTER_DIAG Diagonal interlaced lines
12 FILL_DIAG_THICK_INTER Diagonal interlaced thick
lines
13 FILL_HORIZ_LINES_THIN Horizontal thin lines
14 FILL_VERTICAL_LINES_THIN Vertical thin lines
15 FILL_DIAG_THIN Diagonal thin lines.
16 FILL_INV_DIAG_THIN Inverted diagonal thin lines
17 FILL_HORIZ_INT_THIN Horizontal interlaced thin
lines
18 FILL_HORIZ_INTER_THICK Horizontal interlaced thick
lines
Appendix C. Fill Pattern Constants.
Cell fill pattern constants. Either the numeric value or the constant itself can be used in
operation calls.
fill_option_t
Value Constant Description
0 HALIGN_GENERAL
General horizontal alignment
1 HALIGN_LEFT
Left horizontal alignment
2 HALIGN_CENTER
Center horizontal alignment
3 HALIGN_RIGHT
Right horizontal alignment
4 HALIGN_FILL
Fill horizontal alignment - Fill horizontal alignment - Fill horizontal alignment
5 HALIGN_JUSTIFY
Justify horizontal alignment sample -
Justify horizontal alignment sample -
Justify horizontal alignment sample
6 HALIGN_CENTERACROSS
Center-across horizontal alignment - Center-across horizontal alignment
Value Constant Description
0 VALIGN_TOP
Top vertical alignment
1 VALIGN_CENTER Center vertical alignment
2 VALIGN_BOTTOM
Bottom vertical alignment
3 VALIGN_JUSTIFY
Justify vertical alignment - Justify
vertical alignment - Justify vertical
alignment - Justify vertical alignment
Appendix D. Text Alignment Constants.
Cell horizontal/vertical text alignment constants. Either the
numeric value or the constant itself can be used in operation calls.
halign_option_t
valign_option_t
Value Constant Description
0 ORI_NONE
Default text orientation
1 ORI_TOPBOTTOMTXT
T
o
p
-
b
o
t
t
o
m
t
e
x
t
2 ORI_90NOCLOCKTXT
90 deg. clockwise text orientation
3 ORI_90CLOCKTXT
90 deg. counterclockwise text orientation
txtori_option_t
Value Constant Description
0 BOLDNESS_BOLD Yeico
1 BOLDNESS_HALF Yeico
2 BOLDNESS_NORMAL Yeico
3 BOLDNESS_DOUBLE Yeico
Value Constant Description
0 SCRIPT_NONE Yeico
1 SCRIPT_SUPER
Yeico
2 SCRIPT_SUB Yeico
Value Constant Description
0 UNDERLINE_NONE Yeico
1 UNDERLINE_SINGLE Yeico
2 UNDERLINE_DOUBLE Yeico
3 UNDERLINE_SINGLEACC Yeico
4 UNDERLINE_DOUBLEACC Yeico
underline_option_t
Appendix D. Text Style Constants.
Text style (bold, underline, script) constants. Either the numeric
value or the constant itself can be used in operation calls.
boldness_option_t
script_option_t
Value Constant
0 FMT_GENERAL 12345.12345 = 12345.12345
1 FMT_NUMBER1 12345.12345 = 12345
2 FMT_NUMBER2 12345.12345 = 12345.12
3 FMT_NUMBER3 12345.12345 = 12,345
4 FMT_NUMBER4 12345.12345 = 12,345.12
5 FMT_CURRENCY1 12345.12345 = $12,345
6 FMT_CURRENCY2 12345.12345 = $12,345
7 FMT_CURRENCY3 12345.12345 = $12,345.12
8 FMT_CURRENCY4 12345.12345 = $12,345.12
9 FMT_PERCENT1 12345.12345 = 1234512%
10 FMT_PERCENT2 12345.12345 = 1234512.35%
11 FMT_SCIENTIFIC1 12345.12345 = 1.23E+04
12 FMT_FRACTION1 12345.12345 = 12345 1/8
13 FMT_FRACTION2 12345.12345 = 12345 10/81
14 FMT_DATE1 12345 = 18/10/1933
15 FMT_DATE2 12345 = 18-Oct-33
16 FMT_DATE3 12345 = 18-Oct
17 FMT_DATE4 12345 = Oct-33
18 FMT_HOUR1 12345 = 12:00 a.m.
19 FMT_HOUR2 12345 = 12:00:00 a.m.
20 FMT_HOUR3 12345 = 00:00
21 FMT_HOUR4 12345 = 00:00:00
22 FMT_HOURDATE 12345 = 18/10/1933 00:00
23 FMT_NUMBER5 12345.12345 = 12,345
24 FMT_NUMBER6 12345.12345 = 12,345
25 FMT_NUMBER7 12345.12345 = 12,345.12
26 FMT_NUMBER8 12345.12345 = 12,345.12
27 FMT_ACCOUNTING1 12345.12345 = 12,345
28 FMT_ACCOUNTING2 12345.12345 = 12,345$
29 FMT_ACCOUNTING3 12345.12345 = 12,345.12
30 FMT_ACCOUNTING4 12345.12345 = 12,345.12$
31 FMT_HOUR5 12345 = 00:00
32 FMT_HOUR6 12345 = 296280:00:00
33 FMT_HOUR7 12345 = 00:00.0
34 FMT_SCIENTIFIC2 12345 = 12.3E+3
35 FMT_TEXT 12345 = 12345
Appendix D. Text Alignment Constants.
Number formatting. Either the numeric value or the constant itself can
be used in operation calls.
format_number_t
Sample
Fonts
Arial

Arial Narrow
Arial Narrow
Bookman Old Style
Courier

Helvetica

Σψµβολ


Test
Appendix G. Sample Fonts.
Some font samples. These are only the default installed fonts of MS Excel (TM) (and most of the xls-spreadsheet readers).
The name of the font can be plainly used when assigning the font name (any string is valid).
Note that using non-default fonts is not recommended, since there is no warranty that the font will be installed in the client's
PC.

Navigation menu