Jump to content
We've recently updated our Privacy Statement, available here ×

Freeze panes with JRXlsExporter


tangi

Recommended Posts

Hi,


the "freeze panes" Excel functionality is available in POI, provided by the HSSFSheet. Fortunately, the JRXlsExporter's sheet attribute is protected. Hence, class JRXlsExporter can be subclassed in order to expose the "freeze panes" functionality, see the code below.
 

I'm still searching for the way to do the same when using class JExcelApiExporter instead of class JRXlsExporter, I'll post if I found.
Any idea is welcome, thanks for your attention.
Tangi
 

Code:
package my.jasperreports.engine.export;import java.util.HashMap;import java.util.Map;import net.sf.jasperreports.engine.export.JRXlsExporter;/** * Natively, the JRXlsExporter does not allow to freeze panes in Excel sheets. * This class bypasses the JasperReports API and addresses directly to the POI * API to freeze panes. * @author TME */public class XlsExporter extends JRXlsExporter{	private Map panes;	public XlsExporter()	{		super();		this.panes = new HashMap();	}	/**	 * This overriding method is in charge of creating and freezing a pane.	 * @param	name	sheet name being created	 */	@Override	protected void createSheet( String name )	{		super.createSheet( name );		int[] pane = this.panes.get( name );		if( pane != null )		{			this.sheet.createFreezePane( pane[0], pane[1] );		}	}	/**	 * Defines a pane to create and freeze in the specified sheet.	 * @param sheetName	sheet on which the pane is to be created	 * @param colSplit	column whose right side is split limit (0: no split)	 * @param rowSplit	row whose bottom side is split limit (0: no split)	 */	public void freezePane( String sheetName, int colSplit, int rowSplit )	{		this.panes.put( sheetName, new int[] { colSplit, rowSplit } );	}}
Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...