Skip to main content

MergeExternalExcelFileResults

Structure

MergeExternalExcelFileResults(sFileList, iMergePDFStartPages, iMergePDFEndPages, sPageNumberFormat, dPageNumberX, dPageNumberY, sPageNumberAlign, iPageNumberFontSize)

Type

Function

Description

This procedure will merge a section of results from multiple external Excel files and create a single PDF. The resulting PDF is saved to the database temporarily so it can later be merged with the cert created from PrintBuilder (typically a header page is taken from this cert, then a final page is placed at the end - with the Excel results in the middle of the pdf.) The sections output from each Excel file are defined in the PDF Output worksheet page, just as when the 'Excel w/ PDF Output' test point type is used. The Excel file is typically launched from within the same script project by using the LaunchExternalExcelFile procedure.

Parameters = 8

sFileList = a listing of the Excel files to be merged, files delimited by comma. This should be the full location, including directory/subdirectory + file name + extension.

iMergePDFStartPages = the number of pages that should be taken from the start of the related PrintBuilder certificate, then merged to the beginning of the final PDF, before the Excel results.

iMergePDFEndPages = the number of pages that should be taken from the end of the related PrintBuilder certificate, then merged to the end of the final PDF, after the Excel results.

sPageNumberFormat = After the PDF is created, the page number text is drawn on all pages. This is the format of the text. Note that '[Page]' and '[Total]' merge items are replaced by real values. Example: 'Page [Page] of [Total]'

dPageNumberX = The X position of the page number text on all pages.

dPageNumberY = The Y position of the page number text on all pages.

sPageNumberAlign = The alignment of the page number text from the above position. Possible values are 'LEFT', 'CENTER', and 'RIGHT'.

iPageNumberFontSize = The font size of the page number text on all pages.

Return Value

The function returns either a '1' for success or '0' for failure.

Example

Pascal

sAllExcelFiles := ''; // default
dxmdExcelFiles.DisableControls;
try
dxmdExcelFiles.First;
while not dxmdExcelFiles.EOF do
begin
if sAllExcelFiles <> '' then sAllExcelFiles := sAllExcelFiles + ',';
if Trim(dxmdExcelFiles.FieldbyName('FILE_NAME').AsString) <> '' then sAllExcelFiles := sAllExcelFiles + sIndyTempDir + Trim(dxmdExcelFiles.FieldbyName('FILE_NAME').AsString);

dxmdExcelFiles.Next;
end;
finally
dxmdExcelFiles.EnableControls;
end;

if (Sender = bMergeAll) then
begin
Screen.Cursor := crHourglass;
try
bMerged := MergeExternalExcelFileResults(sAllExcelFiles,
1, // iMergePDFStartPages
1, // iMergePDFEndPages
'Page [Page] of [Total]', // sPageNumberFormat
6.20, // dPageNumberX
10.85, // dPageNumberY
'LEFT', // sPageNumberAlign
10); // iPageNumberFontSize
finally
Screen.Cursor := crDefault;
end;
if not bMerged then ShowMessage('Error: Files NOT merged.')
end;