Excel export on code

Hi,
I want to know if there is a way to use the servoy excel export functionality that is on the menu but calling it from a different location. The thing is that i need to hide the menu and i would love to call that from one of my forms.
Is this possible? how can i do it?

Thanks in advance

As far as I know, I don’t think this is possible.

Would work for you if you hide all other items in the menu/file but leave the ‘export’ option? If so, there are way to manipulate the menu bar and their items in the Window plugin.

Any other ideas. Is what nromeou needs possible in the new Servoy 5.x?

Maybe not what you are looking for but the Data Plug-in offers a lot of (scriptable) Excel functionality.

Not straightforward export unfortunately but you script it definitely!

Have a look here: http://www.it2be.com/plugins/data.php.

Hope this helps

This is probably possible, however I haven’t personally tried it. A few things you could try:

  1. Look at the source code of the excelexport plugin and see the method behind the scenes that it calls
  2. Use the Window (menu in older version) plugin and get the MenuItem object that is the excel export item, and save a reference to its function. Then remove it from the menu. Since you still hold the reference to the function, you should be able to call it.
  3. Just write your own. with a dataset, you can get it as text and format as csv format. Or you can get as HTML and write it to a file with .xls extension, and excel will convert it automatically.

Another “more effort” approach is to create a JasperReport with exactly the fields that you want and in what ever order you want and then run the report export it to excel file.

I’d try #2 suggestion from Scott!

goldcougar:
2. Use the Window (menu in older version) plugin and get the MenuItem object that is the excel export item, and save a reference to its function. Then remove it from the menu. Since you still hold the reference to the function, you should be able to call it.

I think that this option will provide –exactly- what you are looking for.

If I have time next, I’ll try to do this and post the recipe here. It seems that this should work.

Another option is to programatically click the menuItems, using the window plugin: the Menu node has a fucntion doClick();

Paul

pbakker:
Another option is to programatically click the menuItems, using the window plugin: the Menu node has a fucntion doClick();
Paul

Is this possible even when the menu bar is hidden?

Is this possible even when the menu bar is hidden?

I doubt it, as also shortcuts do not work when the menubar is not visible. It should work however when just hiding a menu from the menubar.

Paul

This is what i did:

onOpen, I hide all of the menus.

	plugins.window.getMenuBar().removeMenu(6,5,4,3,2,1,0);

Still, I can use Servoy native export and print menu.

function openPrintExportMenu(){
	plugins.window.getMenuBar().reset();	
	plugins.window.getMenuBar().getMenu(0).doClick();
	//hide again the menus
	plugins.window.getMenuBar().removeMenu(6,5,4,3,2,1,0);	
}

In this way I have: the neat effect of keeping the window without the menus that we don’t use and use the quite good export and print functions of Servoy.

PS: I thought I posted what I did for benefit of the Forum. Now, there it is.

JC

Wacky but it works! Probably use it here I’m sure, thx.

Entirely wacky, I know. Wacky is my specialty.

Once I got a ‘key’ from a software that was built to read to blind people PDF documents. This key was there to unlock protected PDF files in order for the software to read the text back to the blind. So I got this key, I put it in the register of my OCR program … and it worked! The protected PDF documents were being unlocked, OCR’ed, the text extracted (for research purpose) and finally the unlocked ‘public’ document posted in our site. This was totally Wacky.