Do note that the code found in the support site (http://support.jetreports.com/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=131) only allow Excel to launch once.
For example:
I'm unable to launch the report from Navision after the first time unless I close the form and re-launch (which also work for the first time).
With the great help from the in-house NAV consultant, we managed to work around with the below code (maybe Jet folks could provide some good insights on their given code in support site)
We added an additional code "clear(XL)" to allow multiple launching of Jet without closing the form.
IF CREATE(XL, TRUE) THEN BEGIN
XL.Interactive := TRUE;
XL.Visible := TRUE;
XL.Workbooks.Open('C:\Program Files (x86)\JetReports\JetReports.xlam');
Workbook := XL.Workbooks.Open('C:\EZRA\Customer.xls');
//Workbook.Names.Item('PeriodType').RefersToRange.Value := 'Week';
//Workbook.Names.Item('DateFilter').RefersToRange.Value := '1/1/01..3/31/01';
XL.Run('JetMenu','Report');
//XL.Run('Events');
worksheet := Workbook.Worksheets.Item('Record');
worksheet.PrintPreview;
Workbook.Saved := TRUE;
XL.Quit;
CLEAR(XL)
END;
2 comments
-
Jet Reports Historic Posts Jason,
What you did makes sense since the code starts with the line:IF CREATE(XL, TRUE) THEN BEGIN
This means that the code will only be executed if you can create the Excel object. So if you don't call CLEAR(XL) then the object will still exist and you will not be able to create it again the next time you run the code.
Please understand that the code we make available for running Jet from Navision is meant for demonstration purposes only. This code is not meant to produce a finished product in Navision. We expect that someone using this code would be a Navision developer who is experienced working with Navision and COM objects.
Regards,
Hughes -
Jet Reports Historic Posts Hi Hughes,
yes you are right. but dun forget the product is used by end-users and most times end-users like to hands-on (isn't what Jet is trying to do- empowering end users for their reporting).
I feel that we should at least provide a working example and not a demonstrated code that sort of work.
Also, I believe if the customers/end-users engage their Navision vendor to assist them with the correction of the code, they probably will be charged and isn't that defeating the purpose of having a informative JetReports knowledge base article for the faithful Jet users?