| Fields of table: Cell.A1 ... IV65535 | ||
|---|---|---|
| Name | Type | Description |
| pos |
positive-integer (mandatory) |
Specifies the position of a text-string in a text line. If the text-string does not contain included blanks, a script can specify any position within the string and L4X will select the whole string bounded by blanks. If the text-string does contain included blanks then a script must specify the left-most position of the string and supply a value for the len field. |
| len |
positive-integer (optional) |
Specifies the length of a text-string in a text line. Used together with the pos field when the text-string contains included blanks. This field need not be specified for numbers, as long as the value of the pos field specifies the left-most number or the decimal point within the string. |
| line |
integer (mandatory) |
Specifies the line of the text-page from which the text-string is selected. You may specify a negative number where -1 is the last line of a page, -2 is the next to last line, and so on. |
| toline |
integer (optional) |
If a script requires a worksheet cell to contain data from more than one line of text, a script must specify the last line of text from which the text-string is selected. You may specify a negative number where -1 is the last line of a page, -2 is the next to last line, and so on. |
| page |
integer (optional) |
Specifies the page of the text-file from which the
text-string is selected. You may specify a negative
number where -1 is the last page of a file,
-2 is the next to last page, and so on.
The default value is 1, the first page of the file. |
| fmt |
string (optional) |
Specify "number",
"date",
"time",
"datetime",
or "boolean"
when a text-string must be converted to a numeric value.
You may also specify the default value "text" when no conversion is required, or "general", which provides automatic conversion to a numeric value when possible. |
| picture |
string (optional) |
If a script specifies a value for field fmt and the conversion picture in table Sheet.Pictures is not correct for this particular field then a script can specify an alternative picture string here. |
Cell.A2 = {pos=20, line=4, page=1, fmt="number"}
| Fields of table: Column | ||
|---|---|---|
| Name | Type | Description |
| A ... IV | table | You may add new fields to this Column table. The new field name must specify a worksheet column and its value must be a reference to a table that defines which text-strings are read and written to succeeding cells of the named column.. |
| Format.A ... IV | table | Contains a reference to an empty reserved table. You may add new fields to this table, the new field name must specify a worksheet column and its value must be a reference to a table that defines which cells are copied to the specified worksheet column. All cell-references in the copied cell(s) that refer to the first row wll be automatically adjusted to refer to an appropriate range of cells. |
| Heading.A ... IV | table | Contains a reference to an empty reserved table. You may add new fields to this table, the new field name must specify a worksheet column and its value must be a reference to a table that defines how text-string are read and repeatedly written to succeeding cells of the named column. |
| Source | table | Contains a reference to a reserved table that specifies the selection of text-lines. |
| Total.A ... IV | table | Contains a reference to an empty reserved table. You may add new fields to this table, the new field name must specify a worksheet column and its value must be a reference to a table that defines how text-strings are read and repeatedly written to preceding cells of the named column. |
| Fields of table: Column.A ... IV | ||
|---|---|---|
| Name | Type | Description |
| pos |
positive-integer (mandatory) |
Specifies the position of a text-string in a text line. If the text-string does not contain included blanks, a script can specify any position within the string and L4X will select the whole string bounded by blanks. If the text-string does contain included blanks then a script must specify the left-most position of the string and supply a value for the len field. |
| len |
positive-integer (optional) |
Specifies the length of a text-string in a text line. Used together with the pos field when the text-string contains included blanks. This field need not be specified for numbers, as long as the value of the pos field specifies the left-most number or the decimal point within the string. |
| lineofrow |
positive-integer (optional) |
If the contents of one worksheet row are read from multiple text-lines,
a script may specify the sequence number of the line within the set
of lines.
The default value is 1, the first text-line of the set. |
| fmt |
string (optional) |
Specify "number",
"date",
"time",
"datetime",
or "boolean"
when a text-string must be converted to a numeric value.
You may also specify the default value "text" when no conversion is required, or "general", which provides automatic conversion to a numeric value when possible. |
| picture |
string (optional) |
If a script specifies a value for field fmt and the conversion picture in table Sheet.Pictures is not correct for this particular field then a script can specify an alternative picture string here. |
| trim |
boolean (optional) |
Specifies how string with leading blanks are written.
1 or "yes" will cause leading-blanks to be removed before writing.
Default value is "no", leading blanks are not removed before writing. |
| blanktozero |
boolean (optional) |
Specifies how blank strings are converted to numbers. A value of
0 or "no" will cause blank strings to be ignored.
Default value is "yes", blank strings are converted to zero before import. |
| conditionset |
positive integer (optional) |
Specifies the condition(s) to set
when the value of the selected text-string changes.
When the text-string changes, all positive conditions which are lower
than the specified number are also set. Default value is 0, no conditions are set. |
| value |
number (optional) |
Specifies the sequence-number of a delimited-value within a text-string.
The default value is 0 (zero), not a delimited-value. |
| delimit |
string (optional) |
Specifies the character that is used to mark the end of this particular delimited-value.
You may use "*tab" to indicate that the delimiter
is the tab character.
The default value is the value specified in the Sheet.Pictures.delimit field. |
| quote | string |
Specifies the character that is used to "quote" this particular delimited-value.
A delimited-value may be quoted when it
could itself contain a delimiter character. If
a quote character appears within the string
it must be "escaped" by a preceding quote character.
The specified string may be zero characters long,
where a particular delimited-value is not quoted.
The default value is the value specified in the Sheet.Pictures.quote field. |
Column.A = {pos=40, len=30}
Text will only be written to the worksheet when the value of field
Column.Source.condition is equal to zero.
| Fields of table: Column.Format.A ... IV | ||
|---|---|---|
| Name | Type | Description |
| condition |
positive-integer (mandatory) |
Specifies the condition that causes cells to be copied. |
| fromcell |
cell-reference (mandatory) |
Specifies the position of a cell within this worksheet. The contents and formatting of all the cells in the range specified by the fromcell and tocell fields are copied to the named column in the specified row of the work sheet. Formulae in these cells that refer to the first row are adjusted. |
| tocell |
cell-reference (optional) |
Specifies the position of a cell within this worksheet. The contents and formatting
of all the cells in the range specified by the fromcell
and tocell fields are copied to the named column of this work sheet. The default value is the fromcell value. |
| at |
string (optional) |
Specifies where the specified cells are copied to. The string may be one of "start",
"end" or "row". If "start" is specified then
the specified condition signals the start of a set of rows and
the specified cells are copied before the first row of the next set.
If "end" is specified then condition signals the end of a set of
rows and cells are copied onto or after the current row. If "row" is
specified then condition signals one selected row and cells are copied
onto the current row. The default value is "end" |
| functo |
string (optional) |
Specifies a column location to which (the first) adjusted formula in the selected cells
will be copied. Can be specified only when at is "end".
The default value is blank, formula is not copied. |
| insert |
boolean (optional) |
Specify 0 if a script requires the specified cells to be copied to the current row.
Specify 1 if a script requires the cells to be copied to the next row. This value is automatically set to 0 for any "row" groups. The default value is 1 for "start" and "end" groups. |
| remove |
boolean (optional) |
Specify 0 if a script requires the specified cells to be retained in the output worksheet.
Specify 1 if a script requires the cells to be removed from the output worksheet.
The default value is 1, specified cells are removed. |
Column.Format.B = {condition=1, fromcell="X1", tocell="Y1"}
The specified range of cells (X1 to Y1) will copied to column B
only when a condition is set to 1.
| Fields of table: Column.Heading.A ... IV | ||
|---|---|---|
| Name | Type | Description |
| pos |
positive-integer (mandatory) |
Specifies the position of a text-string in a text line. If the text-string does not contain included blanks, a script can specify any position within the string and L4X will select the whole string bounded by blanks. If the text-string does contain included blanks then a script must specify the left-most position of the string and supply a value for the len field. |
| len |
positive-integer (optional) |
Specifies the length of a text-string in a text line. Used together with the pos field when the text-string contains included blanks. This field need not be specified for numbers, as long as the value of the pos field specifies the left-most number or the decimal point within the string. |
| line |
integer (optional) |
Specifies the line of the text-page from which the text-string is read. You may specify a negative number where -1 is the last line of a page, -2 is the next to last line, and so on. |
| page |
integer (optional) |
Specifies the page of the text-file from which the
text-string is read. You may specify a negative
number where -1 is the last page of a file,
-2 is the next to last page, and so on.
The default value 0, selects the text on every page. |
| condition |
positive-integer (optional) |
Specifies the condition
for reading a text-string.
The default value 0 specifies un-conditional reading. |
| lineofrow |
positive-integer (optional) |
If the contents of one worksheet row are read from multiple text-lines,
a script may specify the sequence number of the line within the set
of lines.
The default value is 1, the first text-line of the set. |
| fmt |
string (optional) |
Specify "number",
"date",
"time",
"datetime",
or "boolean"
when a text-string must be converted to a numeric value.
You may also specify the default value "text" when no conversion is required, or "general", which provides automatic conversion to a numeric value when possible. |
| picture |
string (optional) |
If a script specifies a value for field fmt and the conversion picture in table Sheet.Pictures is not correct for this particular field then a script can specify an alternative picture string here. |
| trim |
boolean (optional) |
Specifies how string with leading blanks are written.
1 or "yes" will cause leading-blanks to be removed before writing.
Default value is "no", leading blanks are not removed before writing. |
| blanktozero |
boolean (optional) |
Specifies how blank strings are converted to numbers. A value of
0 or "no" will cause blank strings to be ignored.
Default value is "yes", blank strings are converted to zero before import. |
| value |
number (optional) |
Specifies the sequence-number of a delimited value within a text-string.
The default value is 0 (zero), not a delimited value. |
| delimit |
string (optional) |
Specifies the character that is used to mark the end of this particular delimited-value.
You may use "*tab" to indicate that the delimiter
is the tab character.
The default value is the value specified in the Sheet.Pictures.delimit field. |
| quote | string |
Specifies the character that is used to "quote" this particular delimited-value.
A delimited-value may be quoted when it
could itself contain a delimiter character. If
a quote character appears within the string
it must be "escaped" by a preceding quote character.
The specified string may be zero characters long,
where a particular delimited-value is not quoted.
The default value is the value specified in the Sheet.Pictures.quote field. |
Column.Heading.C = {pos=20, line=5}
The contents of the cell will be read from position 20 of line
5, when each new text-page is read, provided that the value of field
Column.Source.fromline is greater
than 5.
| Fields of table: Column.Source | ||
|---|---|---|
| Name | Type | Description |
| fromline |
positive integer (optional) |
Specifies the starting text line of lines selected
for column processing.
Default value is 1, the first line on the page. |
| toline |
integer (optional) |
Specifies the ending text line of lines selected
for column processing. You may specify a negative
number where -1 is the last line of a page,
-2 is the next to last line, and so on.
Default value is -1, the last line on the page. |
| frompage |
positive integer (optional) |
Specifies the starting text page of pages selected
for column processing.
Default value is 1, the first page in the file. |
| topage |
integer (optional) |
Specifies the ending text page of pages selected
for column processing. You may specify a negative
number where -1 is the last page of text,
-2 is the next to last page, and so on.
Default value is -1, the last page in the file. |
| linesperrow |
positive-integer (optional) |
If the contents of one worksheet row is selected from multiple text-lines, a script must specify the number of lines that will be used to compose each row. The default value is 1. |
| onblankline |
string (optional) |
Specifies the action to be taken when a blank line of text is read.
The string may be one of "ignore",
"endpage" or "endtext". The default value is "ignore". |
| condition |
integer (optional) |
Used in
event functions to
set a condition.
This activates any fields in the
Column.Format,
Column.Heading
and Column.Total tables
with the same number specified as the value of
their condition field.
Setting this value to a non-zero number will de-activate all
Column.A ... IV tables.
Setting this value to a negative number will cause the specified
number of lines to be excluded from column processing.
The value is set to zero, before event functions are called. |
| conditions |
array (optional) |
Used in
event functions to
set one or more conditions.
This activates any fields in the
Column.Format,
Column.Heading
and Column.Total tables
with the same number specified as the value of
their condition field.
Any one of the nine elements of this array can be set, using the index
operator [n], where n is
an integer in the range 1 to 9.
All element values in this array are set to zero, before event functions are called. |
Column.Source = {fromline=10, frompage=1, linesperrow=2}
You may set values for individual fields of this table in
event functions
The following code specifies values for elements
of field conditions.
-- in event functions, Source refers to Column.Source Source.conditions[1] = 1 Source.conditions[9] = 2
| Fields of table: Column.Total.A ... IV | ||
|---|---|---|
| Name | Type | Description |
| pos |
positive-integer (mandatory) |
Specifies the position of a text-string in a text line. If the text-string does not contain included blanks, a script can specify any position within the string and L4X will select the whole string bounded by blanks. If the text-string does contain included blanks then a script must specify the left-most position of the string and supply a value for the len field. |
| len |
positive-integer (optional) |
Specifies the length of a text-string in a text line. Used together with the pos field when the text-string contains included blanks. This field need not be specified for numbers, as long as the value of the pos field specifies the left-most number or the decimal point within the string. |
| condition |
positive-integer (mandatory) |
Specifies the condition for reading a text-string. |
| lineofrow |
positive-integer (optional) |
If the contents of one worksheet row are read from multiple text-lines,
a script may specify the sequence number of the line within the set
of lines.
The default value is 1, the first text-line of the set. |
| fmt |
string (optional) |
Specify "number",
"date",
"time",
"datetime",
or "boolean"
when a text-string must be converted to a numeric value.
You may also specify the default value "text" when no conversion is required, or "general", which provides automatic conversion to a numeric value when possible. |
| picture |
string (optional) |
If a script specifies a value for field fmt and the conversion picture in table Sheet.Pictures is not correct for this particular field then a script can specify an alternative picture string here. |
| trim |
boolean (optional) |
Specifies how string with leading blanks are written.
1 or "yes" will cause leading-blanks to be removed before writing.
Default value is "no", leading blanks are not removed before writing. |
| blanktozero |
boolean (optional) |
Specifies how blank strings are converted to numbers. A value of
0 or "no" will cause blank strings to be ignored.
Default value is "yes", blank strings are converted to zero before import. |
| value |
number (optional) |
Specifies the sequence-number of a delimited value within a text-string.
The default value is 0 (zero), not a delimited value. |
| delimit |
string (optional) |
Specifies the character that is used to mark the end of this particular delimited-value.
You may use "*tab" to indicate that the delimiter
is the tab character.
The default value is the value specified in the Sheet.Pictures.delimit field. |
| quote | string |
Specifies the character that is used to "quote" this particular delimited-value.
A delimited-value may be quoted when it
could itself contain a delimiter character. If
a quote character appears within the string
it must be "escaped" by a preceding quote character.
The specified string may be zero characters long,
where a particular delimited-value is not quoted.
The default value is the value specified in the Sheet.Pictures.quote field. |
Column.Total.D = {pos=20, condition=1}
The text-string will be read from position 20 of the
current line provided that a condition is set
to 1.
| Fields of table: Event | ||
|---|---|---|
| Name | Type | Description |
| OnOpenPage |
function (optional) |
A script may define a Lua function and assign it to this field of this event table. If a script defines this function, it will be called automatically before each page of the text-file is processed. |
| OnOpenRow |
function (optional) |
A script may define a Lua function and assign it to this field of this event table. If a script defines this function, it will be called automatically before each line of the text-file is processed. |
| OnWriteX |
function (optional) |
A script may define a Lua function and assign it to these fields of this event table, where X is a valid column location. If a script defines a function for any particular column, it will be called automatically before text is written to cells in the specified column. |
function Event.OnOpenPage(Page, Source) -- does nothing !! endIf a script defines this function, it will be called automatically before each page of the text-file is processed. The Page parameter passed to the function is a reference to the Sheet.Page table. The Source parameter passed to the function is a reference to the Column.Source table.
function Event.OnOpenPage(Page, Source)
if (strsub(Page.texts[5], 1, 8) ~= "Library:") then
Source.fromline = 10 -- This is not a "header" page
end
end
function Event.OnOpenRow(Page, Source) -- does nothing !! endIf a script defines this function, it will be called automatically before each line of the text-file is processed. The Page parameter passed to the function is a reference to the Sheet.Page table. The Source parameter passed to the function is a reference to the Column.Source table.
function Event.OnOpenRow(Page, Source)
if (strsub(Page.text, 81, 85) == "=====") then
-- exclude this (and the following) line.
Source.condition = -2
end
end
Column.Heading.A = {pos=1, len=30, condition=1}
Column.B = {pos=40, fmt="number"}
Column.Total.C = {pos=60, fmt="number", condition=2}
Then the following function definition, tests for a line beginning with a blank
and, if true, selects the contents of Column.Heading.A
only, but no new worksheet row is added:
function Event.OnOpenRow(Page, Source)
if (strsub(Page.text, 1, 1) == " ") then
-- selects contents of Column.Heading.A only.
Source.condition = 1
end
end
function Event.OnOpenRow(Page, Source)
if (strsub(Page.text, 1, 1) ~= " ") then
-- selects Column.Heading.A and Column.B
Source.conditions[1] = 1
end
end
function Event.OnWriteA(Page, Source) -- does nothing !! endIf a script defines this function, it will be called automatically before text is written to any cell in column: A of a worksheet. A script may contain a definition of an OnWrite function for any column or cell. The Page parameter passed to the function is a reference to the Sheet.Page table. The Source parameter passed to the function is a reference to the Column.Source table.
function Event.OnWriteB(Page, Source)
if (strfind(Page.celltext, "TOTAL FOR") == 1) then
return strsub(Page.text, 15, 66)
end
end
The field: Page.celltext contains the text or number
that will be written to the next cell of column: B.
In this example, the script tests the value of this field, and if it
contains "TOTAL FOR", the function returns an alternative value,
otherwise the value of field
Sheet.Page.celltext
will be written.
| Fields of table: Sheet | ||
|---|---|---|
| Name | Type | Description |
| Out | table | Contains a table that specifies miscellaneous parameters for worksheet output. |
| Page | table | Contains a table that describes the current state of the filter. |
| Pictures | table | Contains a table that specifies the conversion of text-strings into numbers or dates. |
| Write |
function (deprecated) |
Contains a pre-defined function. Use of this function is deprecated but is permitted for backwards compatibility. Please specify a value for field Sheet.Out.row instead. |
| Fields of table: Sheet.Out | ||
|---|---|---|
| Name | Type | Description |
| row |
positive integer (optional) |
Specifies the first worksheet row at which column import starts.
The formats and formulae of all the cells in this row
are automatically copied and adjusted before each new row is imported. Default value is 1. |
| copycells |
positive integer (optional) |
By default L4X will copy all the cells in the first row (see field
row above) and adjust any formulae.
You may specify a value to control how many cells in this row are copied. Default value is 0, all cells in the first row are copied. |
| protect |
boolean (optional) |
Set this value to 0 if you want the output worksheet
to be un-protected, or 1 if it is to be protected.
Only un-protected worksheets in the "scripted" workbook
can be un-protected worksheets in the output workbook.
Default value is 1, protects the output worksheet. |
sheetname |
string (optional) |
Specifies a new name for the worksheet containing this script. |
| vbsave |
boolean (optional) |
Set this value to 1 if you want to save the VB macros
in the "scripted" workbook to the output workbook,
or 0 to discard the VB macros.
Default value is 0, VB macros are not saved. |
| bookpass |
string (optional) |
Specifies a password for the output workbook. If specified this password must be entered before the work book will open. |
| Fields of table: Sheet.Page | ||
|---|---|---|
| Name | Type | Description |
| celltext |
string (readonly) |
Value is the string which will be written to a cell. |
| linecount |
number (readonly) |
Value is the number of lines in the page in process. |
| lineno |
number (readonly) |
Value is the line number of the line in process. |
| pagecount |
number (readonly) |
Value is the number of pages in the text-file. |
| pageno |
number (readonly) |
Value is the page number of the page in process. |
| poscount |
number (readonly) |
Value is the number of characters in each line of the text-file. |
| text |
string (readonly) |
Value is the text from the line in process. |
| texts[] | array of strings | Value is an array of text lines from the page in process. Each line of text can be refenced by the index operator, for example: texts[1] refers to the first line of text in the current page. |
if (Sheet.Page.poscount >= 146) then
Column.M = {pos=137, len=10, fmt="number"}
end
| Fields of table: Sheet.Pictures | ||
|---|---|---|
| Name | Type | Description |
| number | string |
Specifies a string that describes how text is to be converted to
a number. Used when fmt="number" is specified.
The default value "9.9-" defines the localized decimal point (within the nines) and a trailing sign character. |
| date | string |
Specifies a string that describes how text is to be converted to
a numeric date. Used when fmt="date" is specified.
The default value "dd/mm/yy" defines the position of the two digit day dd, month mm and year yy within the text string. |
| time | string |
Specifies a string that describes how text is to be converted to
a numeric time. Used when fmt="time" is specified.
The default value "hh:nn:ss" defines the position of the two digit hour nn, minute nn and seconds ss within the text string. |
| datetime | string |
Specifies a string that describes how text is to be converted to
a numeric date and time.Used when fmt="datetime" is specified.
The default value is "dd/mm/yy hh:nn:ss". |
| boolean | string |
Specifies a string that describes how text is to be converted to
a worksheet boolean value. Used when fmt="boolean" is specified.
The default value "yes" defines the (case-insensitive) text-string equivalent to true. |
| altnumber | string |
Specifies a string that describes how text is to be converted to
a number. Used when fmt="altnumber" is specified.
The default value "(9.9)" defines the localized decimal point (within the nines) and leading/trailing sign characters. |
| altdate | string |
Specifies a string that describes how text is to be converted to
a numeric date. Used when fmt="altdate" is specified.
The default value "dd/mmm/yy" defines the position of the two digit day dd, three-character month mmm and two-digit year yy within the text string. |
| alttime | string |
Specifies a string that describes how text is to be converted to
a numeric time. Used when fmt="alttime" is specified.
The default value "hh:nn" defines the position of the two digit hour nn and minute nn within the text-string. |
| altdatetime | string |
Specifies a string that describes how text is to be converted to
a numeric date and time.Used when fmt="altdatetime" is specified.
The default value is "dd/mmm/yy hh:nn". |
| altboolean | string |
Specifies a string that describes how text is to be converted to
a worksheet boolean value. Used when fmt="altboolean" is specified.
The default value "1" defines the text-string equivalent to true. |
| shortmonthnames | string |
Specifies a string that describes short month names.
These names are used when a date conversion picture
uses mmm to specify the the month positions. The default value "JAN,FEB,MAR,APR,MAY,JUN, JUL,AUG,SEP,OCT,NOV,DEC" may be altered to suit other languages. |
| longmonthnames | string |
Specifies a string that describes the long month names.
These names are used when a date conversion picture
uses mmmm (more than three m characters)
to specify the the month positions.
The default value "January,February, etc" may be altered to suit other languages. |
| delimit | string |
Specifies the character(s) that are used to mark the end of each delimited-value.
You may use "*tab" to indicate that the delimiter
is the tab character.
The default value is , |
| quote | string |
Specifies the character that is used to "quote" a delimited-value.
A delimited-value may be quoted when it
could itself contain a delimiter character. If
a quote character appears within the string
it must be "escaped" by a preceding quote character.
The default value is " |
Sheet.Pictures.number = "-9,9"
Sheet.Write([number | cell-reference | table])By default, column import starts at the row 1 column A of the worksheet. However, the default first-row may be changed by passing an optional parameter, which may be one of:
Sheet.Write(3)
Sheet.Write("A4")
Sheet.Write({row=5})