Excelexport using extended form

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Excelexport using extended form

Postby dfernandez » Tue Oct 18, 2016 6:00 pm

Hi,

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

What am I doing wrong?
dfernandez
 
Posts: 87
Joined: Wed Feb 29, 2012 4:04 pm

Re: Excelexport using extended form

Postby Bernd.N » Wed Oct 19, 2016 2:46 am

I am not familiar with the notation
Code: Select all
[globals.ArrayExcel]

maybe you define the global right away as array.

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.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: Excelexport using extended form

Postby Bernd.N » Wed Oct 19, 2016 7:20 am

So this array from string works, but I would however use application.output() for all elements to check.
array from string.png
array from string.png (4.13 KiB) Viewed 5359 times
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: Excelexport using extended form

Postby dfernandez » Wed Oct 19, 2016 2:33 pm

Hi Bernd,

Thanks for your ideas.

I changed the definition of global variable ArrayExcel to type Array>
/**
* @type {Array<String>}
*
* @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)
dfernandez
 
Posts: 87
Joined: Wed Feb 29, 2012 4:04 pm

Re: Excelexport using extended form

Postby Peter de Groot » Wed Oct 19, 2016 3:08 pm

Hi,

when I run this code

Code: Select all
/** @type {plugins.file.JSFile} */
var $saveToLocation = plugins.file.showDirectorySelectDialog()
if(!$saveToLocation)return;
   
$saveToLocation+='\\exceldump.xls';
var bytes = plugins.excelxport.excelExport(forms['gr_comp_nem'].foundset, ['projectnr', 'ordernr']);
plugins.file.writeFile($saveToLocation, bytes)


I get an excel file at the $saveToLocation,
2016-10-19_1506.png
2016-10-19_1506.png (4.08 KiB) Viewed 5342 times


Regards,
Peter
User avatar
Peter de Groot
 
Posts: 215
Joined: Thu Jan 10, 2008 8:38 pm
Location: Not sure...

Re: Excelexport using extended form

Postby Bernd.N » Wed Oct 19, 2016 3:12 pm

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
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: Excelexport using extended form

Postby dfernandez » Wed Oct 19, 2016 4:37 pm

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?
dfernandez
 
Posts: 87
Joined: Wed Feb 29, 2012 4:04 pm

Re: Excelexport using extended form

Postby Bernd.N » Wed Oct 19, 2016 5:09 pm

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.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: Excelexport using extended form

Postby dfernandez » Wed Oct 19, 2016 5:44 pm

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'];

Thank you!
dfernandez
 
Posts: 87
Joined: Wed Feb 29, 2012 4:04 pm


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 9 guests