WordTemplate Class open setLocale setDataSource process save

WordTemplate.open Method


open(java.lang.String templateFileName)
Opens a WordWriter template specified by file name.
open(java.io.InputStream templateStream)
Opens a WordWriter template from a java.io.InputStream

open(java.lang.String templateFileName)

Syntax:
public void open(java.lang.String templateFileName)
Description:

Opens the WordWriter template specified by the templateFileName parameter. A WordWriter template is a file created in Microsoft Word that contains merge fields.

WordWriter supports Microsoft Word 97, 2000, and 2002 (XP). Do not use open to open files created in earlier versions of Microsoft Word.

Parameters:
Exceptions:
Example:
	...
	oWW = new WordTemplate();
	ServletContext ctx = this.getServletContext();
	oWW.open(ctx.getRealPath("/WordWriterTemplates/Template1.doc"));
	oWW.setDataSource(arrValue, arrName);
	oWW.process();
	oWW.save(response, "Output.doc", true);
	...

Top


open(java.io.InputStream templateStream)

Syntax:
public void open(java.io.InputStream templateStream)
Description:

Opens a WordWriter template from a java.io.InputStream. A WordWriter template is a file created in Microsoft Word that contains merge fields.

WordWriter supports Microsoft Word 97, 2000, and 2002 (XP). Do not use open to open files created in earlier versions of Microsoft Word.

Parameters:
Exceptions:
Example:
	...
	//--- Path to the template file, relative to the Servlet context root.
	String templateFile = "/Basic/StreamIO/StreamIOTemplate.doc";
	//--- Path to the system temp directory, where output files will be stored
	//--- Append either a / or \ to the end to make it a directory path
	String tmpdir = System.getProperty("java.io.tmpdir");
	if(!tmpdir.endsWith(File.separator))
		tmpdir += File.separator;
	WordTemplate oWW = null;
	InputStream iStream = null;
	FileOutputStream outputfstream = null;
	...
	outputfstream = new FileOutputStream(tmpdir + "StreamIOOutput.doc");
	oWW = new WordTemplate();
	iStream = new BufferedInputStream(application.getResourceAsStream(templateFile));
	oWW.open(iStream);
	oWW.setDataSource(arrValue, arrName);
	oWW.process();
	oWW.save(outputfstream);
	...

Top


WordTemplate Class open setLocale setDataSource process save

Copyright © 2003, SoftArtisans, Inc.