Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » how to change export file name
how to change export file name [message #893683] Thu, 05 July 2012 05:09 Go to previous message
smith link is currently offline smith link
Messages: 14
Registered: May 2012
Junior Member
birt 2.3.x



<context-param>
		<param-name>BIRT_FILENAME_GENERATOR_CLASS</param-name>
		<param-value>com.link.report.FilenameGenerator</param-value>
	</context-param>



package jetsennet.jnmp.report;

import java.util.Date;
import java.util.Map;

import org.eclipse.birt.report.utility.filename.IFilenameGenerator;


public class FilenameGenerator implements IFilenameGenerator
{
	/**
	 * default report file name
	 */
	public static final String DEFAULT_FILENAME = "report";

	public String getFilename(String [b]fileName[/b], String extension,
	        String outputType, Map options)
	{
		System.out.println(baseName);
		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;
	}
}





I'd like to use the follow code, but it is unusable!
<birt:viewer id="birtViewer" reportDesign="reports/alarmeventstatisticsnew.rptdesign"
pattern="frameset"
format="HTML"
isHostPage = "true">
<birt:param name="baseName" value="myexportfile"/>
</birt:viewer>


how to change baseName, or how to pass parameter to baseName?

[Updated on: Thu, 05 July 2012 06:13]

Report message to a moderator

 
Read Message
Read Message
Read Message
Previous Topic:Adhoc Reporting in Open Source BIRT
Next Topic:Error in Localization?
Goto Forum:
  


Current Time: Sat May 18 08:46:34 EDT 2013

Powered by FUDForum. Page generated in 0.01592 seconds