Skip to Content
Jun 24, 2010 at 06:58 PM

Not able to export context data to excel in NWDS 7.1


Hi all,

We have a requirement wherein I need to export data from a local context node to an excel file. I am using jxl.jar for this purpose.

I am using a FileDownload UI element to generate the excel. I am working with NWDS 7.1 EhP1.

I am using the following code :

public void excel_download( ) 
	IWDCachedWebResource cachedExcelResource = null;
	String fileName = "TestExcel.xls";
	File f = new File(fileName);
	WritableWorkbook workbook = Workbook.createWorkbook(f);
 	FileInputStream excelCSVFile = new FileInputStream(f);
	cachedExcelResource =getCachedWebResource(excelCSVFile,fileName,WDWebResourceType.getWebResourceType("xls","application/ms-excel"));


private IWDCachedWebResource getCachedWebResource(InputStream file, String name, WDWebResourceType type)
	IWDCachedWebResource cachedWebResource = null;
	if (file != null)
		cachedWebResource = WDWebResource.getWebResource(file, type);	
	return cachedWebResource;

When I try to download the data to excel I am getting the following error:

you must flush before accessing the resource content

But when I deploy the application using NWDS2004s it works perfectly.

Can anyone shed some light on why this may be happening? Am I missing something? Has it got anything to do with the NWDS version?

Thanks and Regards,