I have a base form with the basic navigation functions to move first, last, create, delete and export to excel, and then a form that extends the base one to work with a particular Table.
I can not make the excelexport work. The base form has this code in the excel button:
var formName = application.getActiveWindow().controller.getName();
var bytes = plugins.excelxport.excelExport(forms[formName].foundset, [globals.ArrayExcel]);
plugins.file.writeFile(“ExportedFromServoy.xls”, bytes);
And in OnLoad of the other form:
globals.ArrayExcel = “‘companyname’,‘country’,‘city’,‘contactname’,‘address’”;
When I click, the Excel file is created but no data in it, just a line with companyname’,‘country’,‘city’,‘contactname’,'address
When its not that, did you already check if the foundset really has records?
You could do that either with help of the debug mode (a bit difficult to get into it first, but then it is invaluable), or you create an application.output() before the excel plugin call and send all foundset records to your console with an if-loop.
Also check in the same way if formName is what you expect.
So this array from string works, but I would however use application.output() for all elements to check.
[attachment=0]array from string.png[/attachment]
I changed the definition of global variable ArrayExcel to type Array>
/**
@type {Array}
@properties={typeid:35,uuid:“A4F01D1B-2494-45BC-A1C4-CBDE317A8E67”,variableType:-4}
*/
var ArrayExcel = ;
And change the ExcelExport line to var bytes = plugins.excelxport.excelExport(forms[formName].foundset, globals.ArrayExcel);
No error is shown but when running this error appears in the console, and the Excel file is not generated:
Can’t find method com.servoy.extensions.plugins.excelxport.Enabler.js_excelExport(object,string). (C:\servoy81\demos\Servoy101\forms\FormCRUD.js#39)
Well, I am not a plugin expert, but I guess there will be a comment soon from someone who knows about plugins in detail.
I would check if you use the latest Excel plugin version, and maybe there are some new things to check when using it for Servoy 8.1.
Did you already check the docs for it?
There are lines that the export needs to be enabled for the plugin: https://wiki.servoy.com/display/public/DOCS/excelxport
That option is for the Smart Client, but I am using NGClient. If I pass the IDs in the excelexpxort works fine, but if a use a variable it does not work. Any sample available using a variable for the IDs?
Is your problem still the error message
“Can’t find method com.servoy.extensions.plugins.excelxport.Enabler.js_excelExport(object,string)” ?
I wonder why that would come only when you use a variable.
When using UUIDs I know one has to use .toString() sometimes, to make things work, but I guess that is not related to your case.
Regarding NG I regret that I do not have a suggestion so far.
It is solved!
The onload method was wrong, I was passing a string, not an array.
This way works fine globals.ArrayExcel = [‘companyname’, ‘country’, ‘city’, ‘contactname’, ‘address’];