We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Save gridweb as stream in java from a bean class


I want to add a button under gridweb from where to download the gridweb stream or to the xls to a specific path, the method being implemented in a primefaces bean.
Is this possible?

Thank you!


Could you please elaborate your requirements/issue more. What issue you are facing in your current scenario/case, share your sample code for reference. Do you need to render to XLSX (from GridWeb matrix) on a custom button’s click?

I attach the page here:
image.png (159.5 KB)
the bean method I want to call is:
image.png (44.3 KB)

The parameter gridweb is null, my question is how can I make this connection between these two, to call the bean function with gridweb as parameter


I guess if you need to obtain GridWeb data from a custom command button, you need to register your command button to sink events for getting GridWeb data. This is a line we can normally use on Page_Load event in ASP.NET, e.g.
Button1.Attributes["onclick"] = "GridWeb1.updateData(); return GridWeb1.validateAll();";
so, you may write parallel java code for it at some place where you do initialization for the objects/controls.

1 Like

Can you please show me the Javascript code that the button calls, please?
Thank very much for your help!


We will get back to you soon.

1 Like

we can achiev it through custom button,
here is .net version guide.

however ,there is a bug CELLSJAVA-44838 in java version when using custom command buttons.

We 've fixed it in v22.8.1 .
We will publish the java release version 22.9 in next month.
We will also update the demo in Github and add the java document guide

thank you,
but can it be achieved by adding an external button, not as component in the grid, just on the page? and after get the right instance of the GridWebBean to have the gridweb object in java class?


Ok, we will get back to you to provide assistance on achieving your task via external command button.

1 Like

in page:add a button to trigger js:
//here mycomponent is the gridweb div id ,the second parameter ,just use false is ok
//get gridweb instance and call postBack function
in servlet

  class MyCommandEventHandler implements CustomCommandEventHandler,Serializable{
	private static final long serialVersionUID = 1L;

	public void handleCellEvent(Object sender, String command) {
		GridWebBean gridweb = (GridWebBean) sender;
               //do some thing here ,and get command: hello will be printed
		System.out.print("get command:"+command+"  "+gridweb.getActiveSheet().getName());

 gridweb.CustomCommand=new MyCommandEventHandler();

Here I have my java class:
public class SaveGridWebServlet implements CustomCommandEventHandler,Serializable{

private static final long serialVersionUID = 1L;

public void handleCellEvent(Object sender, String command) {
GridWebBean gridweb = (GridWebBean) sender;
//do some thing here ,and get command: hello will be printed
System.out.print(“get command:”+command+" "+gridweb.getActiveSheet().getName());


// gridweb.CustomCommand=new SaveGridWebServlet();

this is how I called it from the button:

<h:form id=“gridwebForm”
onkeypress=“if (event.keyCode == 13) { return false; }”>
<p:commandButton value=“Back” action="#{nodesBean.backHome}" styleClass=“gridwebButton”
process="@this" />
<p:commandButton value=“Save” onclick=“document.getElementById(‘gridweb’).postBack('CCMD:hello’,false);” styleClass=“gridwebButton”
process="@this" />

It does not seem to call the method when clicking on the button. Have I added it wrongly?
thank you for your support!

please provide your page file.
only normal html button is enough, do not use p:commandButton
just something like:

<button onclick=“document.getElementById(‘gridweb’).postBack('CCMD:hello’,false);console.log('click happen');”>test save</button>

it does not need any form.

1 Like

This is my page file, it is an .xhtml file.

<f:view xmlns=“http://www.w3.org/1999/xhtml
xmlns:p=“http://primefaces.org/ui” contentType=“text/html”

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">


<link rel="stylesheet" type="text/css" href="grid/acw_client/menu.css" />
<link rel="stylesheet" type="text/css" href="Scripts/jquery-ui.css" />

<script src="grid/acw_client/acwmain.js" type="text/javascript"></script>
<script src="grid/acw_client/lang_en.js" type="text/javascript"></script>
<script src="Scripts/jquery-2.1.1.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui.js" type="text/javascript"></script>
<script src="grid/acw_client/jquery-1.7.2.min.js"

	function doClick(method) {
		$.post("FunctionServlet", {
			flag : method.id,
			gridwebuniqueid : $("#mycomponent").attr("webuniqueid")
		}, function(data) {
		}, "html");

	$(document).ready(function() {


		var method = {
			id : "autoFilter"


<div id="gridweb"></div>
<h:form id="gridwebForm"
	onkeypress="if (event.keyCode == 13) { return false; }">
	<p:commandButton value="Back" action="#{nodesBean.backHome}" styleClass="gridwebButton"
		process="@this" />
	<p:commandButton value="Save" onclick="document.getElementById('gridweb').postBack('CCMD:hello',false);" styleClass="gridwebButton"
		process="@this" />



In your page gridweb div id is: mycomponent

so you need to write : document.getElementById(‘mycomponent’).postBack('CCMD:hello’,false);

1 Like
  <div id="gridweb"></div>
    <button onclick=“document.getElementById(‘mycomponent’).postBack('CCMD:hello’,false);console.log('click happen');”>test save</button>
1 Like

Tried this way, thank you, on browser console it is printed the ‘click happenned’ text, but on the server side, the java method is not called

springdemo.zip (858.2 KB)
open and run the project
navigate to
uncheck “show save button”
then click the " test button"

Hi Peter,
I have a question: with what version of aspose-cells should I try it in order to work?
Thank you very much for help!


Please try using latest Aspose.Cells.GridWeb (Java) with latest resource files.