Implementing custom excel export functionality in efw reports

Hello Team Helical,
I would like to know the implementation of custom excel export functionality in efw reports. I am using Helical Insight version 3.1

Thank You
Kevin.

1 Like

Hello Kevin,

This plugin is implemented using the custom java functionality available in Helical Insight. We will explain the usage of this plugin with a samle report , in the similar way it can be used for any efw report

Steps to deploy :

Download the zip file Excel_Export_Plugin.zip (7.4 MB)

1.Copy the hwf folder in the β€œhi-repository”
2.Copy library files into the path β€œhi\apache-tomcat-7\webapps\hi-ee\WEB-INF\lib”
3.Copy jsp file into the path β€œhi\apache-tomcat-7\webapps\hi-ee\WEB-INF\jsp”
4.Open β€œhwf-controller” folder and copy β€œhwf” folder in the below path

…\hi\apache-tomcat-7\webapps\hi-ee\WEB-INF\classes\com

5.Open β€œapplication-context.xml” in the below server location :…\hi\apache-tomcat-7\webapps\hi-ee\WEB-INF\classes
Add the below bean :

<bean class="com.helical.efw.cache.ExportCache" id="exportCache">
		<property name="cacheService" ref="cacheServiceImpl"/>
</bean>

6.Restart the Helical Insight server

Steps to use excel export functionality for ewf report :

1.Open the hi-repository in the server installation path :
…/opt/Helical Insight 3.1/hi/hi-repository
2.Open the β€œSample_Piechart” report files path , it contains below files
pie_chart.html
pie_chart.efwd
pie_chart.efwvf
pie_chart.efw
3.Open the pie_chart.html file in edit mode
4.Add the code for excel button :

<div id="EXCEL" align='right' class="hi_export" style="padding-right: 100px; ><a href="#"><button>EXCEL</button></a></div>

image

5.In js script add the below code :

$("#EXCEL").on('click', function() {
				<!-- var limit =  -->
				//var limit = parseInt(dashboard.getVariable('visitDateParam').length) * 2000 ;
				var numberOfRecordsToExport =2000;
				<!-- var numberOfRecordsToExport =" "; -->
				Dashboard.setVariable('numberOfRecordsToExport',numberOfRecordsToExport);

    var dataToSend = [
	{
		reportName: 'genderPieChart',
		numberOfRecordsToExport: Dashboard.getVariable('numberOfRecordsToExport'),
        dir: window.DashboardGlobals.folderpath,
        map_id: 1
    }
	
	];

		var url=window.DashboardGlobals.baseUrl + 'workflow.html?dir=hwf&fileName=ExportToExcel_v1.hwf' ;
		

	 
	 openHWF = function(verb, url, data, target) {
		 var form = document.createElement("form");
		 form.action = url;
		 form.method = verb;
		 form.target = target || "_self";
	     if (data) {
				for (var key in data) {
				  var input = document.createElement("textarea");
				  input.name = key;
				  input.value = typeof data[key] === "object" ? JSON.stringify(data[key]) : data[key];
				  form.appendChild(input);
				}
		   }
		 form.style.display = 'none';
		var excelFileName=DashboardGlobals.fileTitle;
		
		var reportName = document.createElement("input"); //input element, text
		reportName.setAttribute('type',"text");
		reportName.setAttribute('name',"reportName");

		reportName.setAttribute('value',excelFileName+"_");

		form.appendChild(reportName);
		
		 document.body.appendChild(form);
        
			
		 $.notify({message: "Maximum 2000 records can be exported", icon: "fa fa-exclamation-triangle"}, {type: "info"});	
		 form.submit();			 
	   };
  
		openHWF('POST',encodeURI(url), {query: JSON.stringify(dataToSend), dataCountPerSheet: '2000'} ,'_self' );
		Dashboard.setVariable('numberOfRecordsToExport','');
		

});

Test Case :

If we open report in open mode , the excel button will be displayed.
image

If we click on β€˜EXCEL’ button , the data of the chart will be downloaded in excel.
image
Note : The excel file name will be β€˜Efw report name’

Thank You
Team Helical