XLSREPORT_CreateFromTemplateΒΆ
XLSREPORT_CreateFromTemplate inserts data into an MS-Excel template.
-
bool = XLSREPORT_CreateFromTemplate(ssTemplate, svDataFileName)
Return Value
If the function succeeds, the return value bool is TRUE (1); otherwise it is FALSE (0).
Parameters
-
ssTemplate
ssTemplate is the Name of an Excel file. If the file name is specified without the drive and path name the file must be located in one of the specified search directories.
-
svDataFileName
svDataFileName string vector with data file names. The files will be converted into the NC file format.
Comment
UniPlot can be used to insert data from any supported data file format into prepared MS-Excel templates. To use this function MS-Excel 97 or MS-Excel 2000 must be available on your computer.
To prepare a template you need to create an Excel template and a UniScript file. The Excel template can have multiple sheets. Each sheet contains place-holders which will be filled by UniPlot. The template also contains the complete layout. The UniScript file controls the report creation, UniPlot uses the Excel ActiveX interface.
The Excel Template:
Place-Holders:
The template can contain any number of text place-holders which will be replaced by data from the NC files during the execution of the automation script. Place-holders can be specified for global attributes, for channel attributes and for channel data.
Attribute Place-Holder:
A place-holder is text that begins with a dollar sign, followed by the text,
followed by another dollar sign, e.g.``$Operator$`` is a placeholder for a global
attribute. For a channel attribute the channel name followed by a period (.)
is placed before the attribute name, e.g. $EngSpd.units$
.
If you need a access an attribute from a specific file you can add a file alias
to the placeholder, e.g. $File1:Operator$
. The placeholder
$File2:Operator$
would be replaced by the value of the attribute Operator of
the second file.
Channel-Data Place-Holders:
The channel name is enclosed in asterisk, e.g.: *EngSpd*
. UniPlot will insert
the data of the specified channel as a column into the Excel template. The first
value will beplace the place holder. The number of decimal places, font, font
size, etc. can be specified in the Excel template.
The following figure is an Excel template. Header data (global attributes) is located in the upper part, the data channels are placed below the header data.
The source code of this example as well as the Excel template can be found in the
\UniPlot\samples\automate
directory. The name of the
UniScript file is UP_Temp.ic
. The name of the Excel template
is UP_Temp.xls
. The appropriate data file is also found in this
directory, WOT_XLS.utx
. For this data file the UTX file converter need to
be installed (command: Tools=>Add-In Manager).
To load this UniScript function, the path name of the source code must be
specified in the dialog box Tools=>More Options in the
field Search path for automation scripts
(e.g. C:\Program Files\UniPlot\Samples\Automate
).
Multi line tables:
If a record does not fit into a single line, the record can be split into several lines. To separate the multi line blocks by an empty line the key word EMPTYROW can be placed into one row. The cells that contain the channel place holders also contain the complete cell format. (fill color, font color, number format, font frame, alignment, etc.). UniPlot will copy the format into all consecutive cells for the specified channel.
Every channel can be occure more than ones. If a row numbering is useful, the key word ROWCOUNTER can be inserted into the template instead of a channel name.
The following figure shows a multi line template:
More about Automation is found here Overview Automation.
To start a report choose Reports=>Example Excel-Report.
You see the result in the following figure:
auto_AddToUI("Example Excel-Report", "Report1", "RSXLS_Template1");
def RSXLS_Template1()
{
ssXLSTemplate = "UP_Temp.xls"
svFile = auto_GetFileNameDialog(1, "Excel-Report");
XLSREPORT_CreateFromTemplate(ssXLSTemplate, svFile);
}
See also
id-489661