Hi.
My BIRT Version: 2.5.2
Tomcat Version: 6.0
my requirement is, while exporting the report to excel, the file name of the excel should be "Name_of_the_file & Date of exporting". In order to do that i followed this link:
"
http://birtworld.blogspot.in/2008/09/naming-exported-files-from-birt.html"
But i am getting default file name only instead of what i am expecting. Here i have mentioned the 2 different ways that i follwed.
First Way:
1. I aaded to web.xml
<context-param>
<param-name>BIRT_FILENAME_GENERATOR_CLASS
<param-value>org.eclipse.birt.report.utility.filename.MyFilenameGenerator
</context-param>
2. Create a java class in report project
package my.filename.generator;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.eclipse.birt.report.utility.filename.*;
public class MyFilenameGenerator implements IFilenameGenerator{
public static final String DEFAULT_FILENAME = "BIRTReport"; //$NON-NLS-1$
public String getFilename( String baseName, String extension, String outputType, Map options )
{
HttpServletRequest httpr = (HttpServletRequest) options.get("httpRequest");
if( httpr !=null){
String parm = httpr.getParameter("__filename");
if( parm != null && parm.length() > 0 ){
return parm;
}
}
return makeFileName( baseName, extension );
}
/**
* Makes a filename using the target extension from the options.
*
@param fileName file name which extension must be replaced
*
@return file name with replaced extension
*/
public static String makeFileName( String fileName, String extensionName )
{
String baseName = fileName;
if (baseName == null || baseName.trim().length() <= 0)
{
baseName = DEFAULT_FILENAME;
}
// check whether the file name contains non US-ASCII characters
for (int i = 0; i < baseName.length(); i++) {
char c = baseName.charAt(i);
// char is from 0-127
if (c < 0x00 || c >= 0x80) {
baseName = DEFAULT_FILENAME;
break;
}
}
// append extension name
if (extensionName != null && extensionName.length() > 0) {
baseName += (new Date()).toString() + "." + extensionName; //$NON-NLS-1$
}
return baseName;
}
}
Second Way:
1.I aaded BIRT_FILENAME_GENERATOR_CLASS to jar file name in web.xml
<context-param>
<param-name>BIRT_FILENAME_GENERATOR_CLASS
<param-value>filenamegenerator
</context-param>
2.Download the jar file from this link and added to the WEBINF/lib
Can anyone please help me?