Alfresco Share-Export to Excel from YUI Data table without using Repo Webscript

  • In Alfresco share, some details are being fetched dynamically and displayed using YUI data table on any page. Many times, there is a requirement to export this YUI datatable information to EXCEL file.

  • To provide Save As/ Download option to user for any such dynamic data, first we need to store that data in a file in alfresco repository and then we can easily give download option to any user.

  • But for EXCEL file, we can directly give option to download without storing to the repository.

  • To achieve this, define one action listener on any button/link to call export funtion in javascript file.

  • On clicking of that link/button, make a call to below function “exportToEXCEL” by passing the datatable object and one Boolean parameter indicating include last column or not.

Parameters Format:

var options =

{

datatable: // your YUI datatable object

includeLastColumn: true/false

};

Javascript Fucntion

exportToEXCEL : function exportToEXCEL(e,options)

{

var tab_text=“<table border=’2px’><tr bgcolor=’#87AFC6′><td>”;

var textRange; var j=0;

table = options.datatable; // id of table

var i,j,k, oData;

var includeLastColumn=true;

var aRecs = table.getRecordSet().getRecords(),aCols = table.getColumnSet().keys;

var aColsLength = aCols.length;

var aRecsLength = aRecs.length;

for(i=0; i < aColsLength; i++)

{

tab_text += aCols[i].label.replace(/(&nbsp;)*/g,“”).replace(/<br[^>]*>/g,” “) + ( i < aColsLength ? “</td><td>” : “”);

}

tab_text += “</td></tr><tr><td>”;

for (j=0; j<aRecsLength; j++) {

oData = aRecs[j].getData();

for (k=0; k < aColsLength; k++) {

tab_text += ( oData[aCols[k].key] + ( k < aColsLength ? “</td><td>” : “”));

}

tab_text += “</td></tr><tr><td>”;

}

tab_text=tab_text+“</td></tr></table>”;

tab_text= tab_text.replace(/<A[^>]*>|<\/A>/g, “”);//remove if u want links in your table

tab_text= tab_text.replace(/<img[^>]*>/gi,“”); // remove if u want images in your table

tab_text= tab_text.replace(/<input[^>]*>|<\/input>/gi, “”); // reomves input params

var thisForm = document.createElement(‘form’);

thisForm.style.display = ‘none’;

document.body.appendChild(thisForm);

var fileName = document.createElement(‘input’);

fileName.type = ‘hidden’;

fileName.name = ‘fileName’;

fileName.value = ‘DMS Report–‘+new Date();

thisForm.appendChild(fileName);

var dataTable = document.createElement(‘input’);

dataTable.type = ‘hidden’;

dataTable.name = ‘tableData’;

dataTable.value = tab_text;

thisForm.appendChild(dataTable);

thisForm.method = ‘POST’;

thisForm.action = Alfresco.constants.URL_CONTEXT+“page/csv-download”;

thisForm.submit();

document.body.removeChild(thisForm);

}

And create the following files in following locations:

  • .Page descriptor file – excel-download.xml 

 – Should be kept under /shared/classes/alfresco/web-extension/pages

<?xml version=’1.0′ encoding=’UTF-8′?>
<page>
<title>Excel Download</title>
<title-id>page.siteIndex.title</title-id>
<description>Downloads the Excel file of YUI datatable</description>
<description-id>page.siteIndex.description</description-id>
<template-instance>excel-download</template-instance>
<authentication>user</authentication>
</page>

  • Template instance file – exceldownload.xml

Should be kept under /shared/classes/alfresco/web-extension/pages/template-instances

<?xml version=’1.0′ encoding=’UTF-8′?>
<template-instance>
<template-type>excel-download</template-type>
</template-instance>

  • Template type – exceldownload.xml

Should be kept under /shared/classes/alfresco/web-extension/pages/template-types

<?xml version=”1.0″ encoding=”UTF-8″?>
<template-type>
<title>Excel Download</title>
<description>Excel Download</description>
<!– Define the rendering processors for this template type –>
<processor mode=”view”>
<id>jsp</id>
<jsp-path>/excelDownload.jsp</jsp-path>
</processor>
</template-type>

  • excelDownload.jsp

<ALF_INSTALL_HOME>/tomcat/webapps/share.

<%@ page language=”java” import=”java.util.*” pageEncoding=”ISO-8859-1″%>
<%@page contentType=”application/octet-stream” %>
<%
String tableData = “No records found”;
String fileName = “datatable”;

if(request.getParameter(“fileName”) != null || request.getParameter(“fileName”)!= “”)
{
fileName = request.getParameter(“fileName”);
}
if(request.getParameter(“tableData”) != null || request.getParameter(“tableData”)!= “”)
{
tableData = request.getParameter(“tableData”);
}

response.setHeader (“Content-Disposition”,”attachment;filename=\””+fileName+”.xls\””);

out.print(tableData);
%>

<ALF_INSTALL_HOME> stands for Alfresco installation directory.

– After that restart the server and check any YUI datatable export.

– For exporting into csv please refer the following link

http://aaditvm.blogspot.in/2013/08/alfresco-share-export-yui-datatable-to.html

Posted in Uncategorized | Tagged , | 1 Comment

Alfresco community 4.2.b installation with MySQL database for windows

  • First install MYSQL server
  • Create a database instance of Alfresco repository. Execute the following script:
    CREATE USER alfresco@localhost IDENTIFIED BY ‘alfresco’;
    create database alfresco DEFAULT CHARACTER SET utf8;
    grant all on alfresco.* to alfresco@localhost identified by ‘alfresco’ with grant option;
    FLUSH PRIVILEGES;
  • Now Click here to download the “alfresco-community-4.2.b-installer-win-x64”.
  • Double click “alfresco-community-4.2.b-installer-win-x64”

Untitled1

Untitled1

  • Select Installation type as Advanced.

Untitled1

  • Uncheck PostgreSQL database

Untitled1

Untitled1

Untitled1

  • Modify JDBC URL to : jdbc:mysql://localhost/alfresco
    JDBC Driver: org.gjt.mm.mysql.Driver
    Username: alfresco
    Password:

Untitled1

Untitled1

Untitled1

Untitled1

 

Untitled1

Untitled1

Untitled1

Untitled1

Untitled1

Untitled1

  • Open <ALFRESCO_INSTALLATION_HOME>/tomcat/conf/catalina.properties 
  • Verify shared.loader is set to following value:

     shared.loader=${catalina.home}/shared/classes,${catalina.home}/shared/lib/*.jar or
     shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar

  • Next modify global.properties
  • Edit <ALFRESCO_INSTALLATION_HOME>/tomcat/shared/classes/alfresco-global.properties

Verify following database connection properties are set properly:
### database connection properties ###
db.driver=org.gjt.mm.mysql.Driver
db.username=alfresco
db.password=admin@cml
db.name=alfresco
db.url=jdbc:mysql://localhost/alfresco
db.host=localhost
db.port=3306
db.url=jdbc:mysql://${db.host}:${db.port}/${db.name}

  • Make sure that database username and password are specified correctly.
  • Copy mysql-connector-java-5.1.20-bin.jar from “<MYSQL_INSTALLATION>\Connector J 5.1.20.0” to <ALFRESCO_INSTALLATION_HOME>/tomcat/lib
  • Start Alfresco server:
  • Verify that MySQL server is up and running.
  • Double click “manager-windows.exe”

Untitled1

  • Click on “Start”
  • Creation of user with readonly permission for Alfresco database:

Untitled1

  •  Click on Manage security

Untitled1

  •  Click on Add Account

Untitled1

username: alfdb_user
password:

  • Click on Apply.
  • Click on schema privileges
  • Select alfdb_user then click on Add Entry.

Untitled1

  •  Select only alfresco schema and click OK

Untitled1

  •  Select only “SELECT” option and click save changes

 

Posted in Uncategorized | Leave a comment

Headstart script error in Documentum 6.6 Developer edition Installation

While trying to install content content server 6.6 in windows server 2008 with data base SQL Server , the content server will get successfully installed.

But, while doing server configuration we will face errors like this(shown in below screenshot) …

1

 

to over come this ,

we need to modify headstart.ebs file after installing content server(before starting server configuration).

a) Search for the headstart.ebs. It should be under $DM_HOME/install/admin
b) Open the file in a editor and search for the text “If ftEngine”
c) The entry would be like this:
If ftEngine = “Fast” Then
        FTVendorStr = “fast”
d) Change it to:
If ftEngine = “Fast” Then
        FTVendorStr = “lucene”
e)Save

 

 

 

 

Posted in Uncategorized | Leave a comment