Four Js Development Tools Forum

Discussions by product => Genero BDL => Topic started by: Malabad P. on May 11, 2017, 05:43:50 pm



Title: Wincom saveas in BDL 2.02.10
Post by: Malabad P. on May 11, 2017, 05:43:50 pm
I have been able to successfully create a spreadsheet in excel using wincom, but I cannot seem to save the file programmatically.

DEFINE xlapp INTEGER
DEFINE xlwb INTEGER
DEFINE result INTEGER
DEFINE filename STRING

  LET xlapp = -1
  LET xlwb = -1
  CALL ui.Interface.frontCall("WinCOM", "CreateInstance", ["Excel.Application"], [xlapp])
  CALL ui.interface.frontCall("WinCOM", "CallMethod",[xlapp, "WorkBooks.Add"], [xlwb])

....
  LET wfname='c:\\tmp\\testfile.xls'
  CALL ui.Interface.frontCall("WinCOM","CallMethod",[xlapp,"Workbook.SaveAs",wfname],[res])

Errors out with
One or more of the names were not known. The returned array of DISPIDs contains DISPID_UNKNOWN for each entry that corresponds to an unknown name.

I have also tried
  LET wfname='filename:=c:\\tmp\\testfile.xls'
  CALL ui.Interface.frontCall("WinCOM","CallMethod",[xlapp,"Workbook.SaveAs",wfname],[res])
with similar results.

I have also swapped the xlapp with xlwb in case that was it.

I know I am close, but cannot succeed.

Thanks,




Title: Re: Wincom saveas in BDL 2.02.10
Post by: Lionel F. on May 11, 2017, 07:03:10 pm
Hi Malabad,

I've been able to make it work successfully using the following syntax :
Code
  1. CALL ui.interface.frontcall("WinCOM", "CallMethod", [xlapp, 'ActiveWorkbook.SaveAs("c:\\tmp\\file.xls")'], [xlwb])
  2.  

Nevertheless, please consider two points :
- 2.02.10 is a very old version (more than 9 years old), think about upgrading for getting new bugfixes and enjoying new stuffs/features. The current version is 3.0 and 3.10 is scheduled for end of June.
- Wincom is a strict GDC solution which cannot be ported.  Consider using a server side solution (for example Apache POI: http://4js.com/online_documentation/fjs-fgl-manual-html/?path=fjs-fgl-manual#c_fgl_JavaBridge_example_2.html) if you expect to move to Genero Web Client in the future.

Best Regards,
Lionel