MoorthiDaniel.com

Export to symphony from xpage

Posted on: February 21st, 2012 by daniel

Lotus Symphony is the open source alternative for Microsoft Excel. It uses the odf format. It is calculating speed is faster than the MS Excel.

The main difference between exporting to excel and symphony is a matter of 3 lines of code

response.setContentType("application/x-vnd.oasis.opendocument.spreadsheet");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Content-Disposition","attachment; filename=export.ods");

Here we are creating the writter object for getResponseWriter and formatting the data using html table tags.

var writer = facesContext.getResponseWriter();
writer.write("<table>");
writer.write("<thead><tr>");
writer.write("<td><b>Your Header</b></td>");
writer.write("</tr></thead>");
writer.write("<tbody><tr>");
writer.write("<td><b>Your Data for column1</b></td>");
writer.write("</tr></tbody>");
writer.write("</table>");

 

Source code for the xpage

<!--?xml version="1.0" encoding="UTF-8"?-->
<![CDATA[#{javascript:var exCon = facesContext.getExternalContext();
var writer = facesContext.getResponseWriter();
var response = exCon.getResponse();
var projects:NotesView = database.getView('Companies')
var viewNav:NotesViewNavigator = projects.createViewNav();
var viewEnt:NotesViewEntry = viewNav.getFirst();
var output:string = "";
while (viewEnt != null) {
output += "<tr>";
output += "<td>" + viewEnt.getColumnValues()[0]; + "</td>";
output += "<td>" + viewEnt.getColumnValues()[1] + "</td>";
output += "<td>" + viewEnt.getColumnValues()[2] + "</td>";
output += "<td>" + viewEnt.getColumnValues()[3] + "</td>";
output += "<td>" + viewEnt.getColumnValues()[4] + "</td>";
output += "</tr>";
viewEnt = viewNav.getNext(viewEnt);
}
response.setContentType("application/x-vnd.oasis.opendocument.spreadsheet");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Content-Disposition","attachment; filename=export.ods");
writer.write("<table>");
writer.write("<thead><tr>");
writer.write("<td><b>Branch Id</b></td>");
writer.write("<td><b>Company Name</b></td>");
writer.write("<td><b>Share value</b></td>");
writer.write("<td><b>City</b></td>");
writer.write("<td><b>Country</b></td>");
writer.write("</tr></thead>");
writer.write(output);
writer.write("</table>");
writer.endDocument();}]]>

Export to excel from xpage

Posted on: February 21st, 2012 by daniel

At times we need to create export excel report from the view. Below is the simple way to do that.
1. Create a new xpage and go to all properties.
2. Change the Rendered property to false

Source for the xpage

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" rendered="false">
        <xp:this.afterRenderResponse><![CDATA[#{javascript:var exCon = facesContext.getExternalContext();
    var writer = facesContext.getResponseWriter();
    var response = exCon.getResponse();
    var projects:NotesView = database.getView('Companies')
    var viewNav:NotesViewNavigator = projects.createViewNav();
    var viewEnt:NotesViewEntry = viewNav.getFirst();
    var output:string = "";
    while (viewEnt != null) {
     output += "<tr>";
     output += "<td>" + viewEnt.getColumnValues()[0]; + "</td>";
     output += "<td>" + viewEnt.getColumnValues()[1] + "</td>";
     output += "<td>" + viewEnt.getColumnValues()[2] + "</td>";
     output += "<td>" + viewEnt.getColumnValues()[3] + "</td>";
     output += "<td>" + viewEnt.getColumnValues()[4] + "</td>";
     output += "</tr>";
    viewEnt = viewNav.getNext(viewEnt);
    }
    response.setContentType("application/vnd.ms-excel");
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Content-Disposition","attachment; filename=export.xls");
    writer.write("<table>");
    writer.write("<thead><tr>");
    writer.write("<td><b>Branch Id</b></td>");
    writer.write("<td><b>Company Name</b></td>");
    writer.write("<td><b>Share value</b></td>");
    writer.write("<td><b>City</b></td>");
    writer.write("<td><b>Country</b></td>");
    writer.write("</tr></thead>");
    writer.write(output);
    writer.write("</table>");
    writer.endDocument();}]]></xp:this.afterRenderResponse>
    </xp:view>

Scrab a web site content using lotus script

Posted on: February 15th, 2012 by daniel

Scraping a web site is important for sending email newsletters or updating part of the application. we can scrap a website content from lotus script itself. This is very simple script to fetch the content from a website. Use the below script to do that. If you want to remove the js from website content, search for the script tag ans remove those block.

Read the rest of this entry »

Identify a text or text list is empty or not

Posted on: February 15th, 2012 by daniel

We can use getitemvalue and checking the 0 index value like var(0). Another way we can do is like using a method available for notesitem class. it is notesitem.text. Read the usage in help file carefully. For multiple values in a list are separated by semicolons in the returned string. If an item’s value is large, the returned string may be truncated. For rich text items, this property skips non-text data such as bitmaps and file attachments. For HTML items, this property returns Null.

Read the rest of this entry »

Lotus Notes and Domino links

Posted on: February 13th, 2012 by daniel

When I am learning lotus notes and want to find some solution, I found some web sites are very useful. Many of may aware of these website and some may not. These links will be helpful for beginners and people who want to learn more on lotus notes. Read the rest of this entry »

Freshers Job search in India

Posted on: February 8th, 2012 by daniel

Recently I come across some web sites who providing the job opening for freshers as well as experienced candidates in India. Many peoples are not aware all the web sites. so I thought of sharing them in one place will help others. I have not used all the web sites but suggested by others. Read the rest of this entry »

Riya 02 – Theme

Posted on: January 27th, 2012 by daniel

A simple clean layout for wordpress blog. This theme is based on popular blueprint css framework.

2X2 Column layout.

Blueprint CSS frame work

Download

Export to excel or csv using lotus script

Posted on: September 24th, 2011 by daniel

Here is the pretty simple lotus script to export the current view to excel or csv. It can export either selected documents from the current view or entire view.

Read the rest of this entry »

How to get Lotus Notes temporary directory

Posted on: July 25th, 2011 by daniel

Using lotus script you can get the temporary directory used by notes. Irrespective of the OS(windows or mac or linux) used for lotus notes, by using following code it is achievable.

Read the rest of this entry »

Reserved fields for lotus domino web applications

Posted on: July 25th, 2011 by daniel

There are several reserved fields available. I am listing some of those fields which I used frequently.

1. $$HTMLFrontMatter
By default domino will be generating the DocType url without the DTD defenition like this below

Read the rest of this entry »


Valid XHTML 1.0 Transitional