Export Coach Table into CSV format Excel
//Supports multiple Export CV in one page. // Set Form and Field Name to use the viewId . var viewId = this.context.viewid; var thisFormName = "csvExportData_"+viewId; this.context.element.getElementsByTagName("form")[0].name = thisFormName; //Set export image var imgData = this.context.element.getElementsByTagName("img")[0]; //CSV Export Logo // legacy file path /portal/jsp/images/reporting/enabled/export_16x16.gif // The image file is added as a File resources named "export_16x16.gif" and loaded through this JS API. var excelImg = com_ibm_bpm_coach.getManagedAssetUrl("export_16x16.gif", com_ibm_bpm_coach.assetType_WEB); imgData.src = excelImg; //defined in inline javascript //CSV Data if ( this.context.binding && this.context.binding.get("value") != undefined ){ var csvData = this.context.element.getElementsByTagName("input" )[0]; var textData = this.context.binding && this.context.binding.get("value") != undefined && (typeof this.context.binding.get("value") === "string") ? this.context.binding.get("value") : ""; //Data should be escaped already csvData.value = textData; //this.context.htmlEscape(textData); } //CSV File Name if( this.context.options.csvFileName && this.context.options.csvFileName.get("value") != undefined && this.context.options.csvFileName.get("value") != ""){ // File name : value="filename=ReportData.csv" var csvFileName = this.context.element.getElementsByTagName("input" )[1]; var textFileName = (typeof this.context.options.csvFileName.get("value") === "string") ? this.context.options.csvFileName.get("value") : ""; if(textFileName != ""){ csvFileName.value= "filename="+textFileName+".csv"; } } //Link Text if( this.context.options.linkTitle && this.context.options.linkTitle.get("value") != undefined && this.context.options.linkTitle.get("value") != ""){ var exportLinkTitle = (typeof this.context.options.linkTitle.get("value") === "string") ? this.context.options.linkTitle.get("value") : "Export"; //add text after the img dom element inside the link <a></a> var txt = document.createTextNode(exportLinkTitle); var linkDom = this.context.element.getElementsByTagName("a")[0]; linkDom.appendChild(txt); } //Set link onclick action for this form this.context.element.getElementsByTagName("a")[0].onclick=function(){ document.forms[thisFormName].submit(); return false; };