ASP.NET Reference: WordTemplate Object Open SetCultureInfo SetDataSource GetVersion Process Save
ASP Reference: WordTemplate Object Open SetCultureInfo SetDataSource GetVersion Process Save

ASP.NET Programmer's Reference

WordTemplate.SetCultureInfo Method


C# Syntax:
public void WordTemplate.SetCultureInfo(System.Globalization.CultureInfo cultureInfo);
VB.NET Syntax:
Public Sub WordTemplate.SetCultureInfo(cultureInfo As System.Globalization.CultureInfo)
Description:

The SetCultureInfo method allows you to override the server's default locale when generating a new Word file. For example, to generate a US English document on a French operating system, you could use SetCultureInfo to set the Word file's CultureInfo to US English.

Parameter:

SetCultureInfo takes a System.Globalization.CultureInfo object. This object represents information about a culture including its alphabet, calendar, and date formats.

The CultureInfo object is in the System.Globalization namespace. Use an Import directive to import this namespace to the aspx page:

	<%@ Import Namespace="System.Globalization" %>

The CultureInfo passed to SetCultureInfo must include both language and country (for example "fr-BE" for French-Belgium). WordWriter will throw an exception if the CultureInfo object passed to SetCultureInfo is invariant (an empty string) or neutral (for example, "en" rather than "en-US" or "en-AU").

See CultureInfo Class for more information about the class, its members, and a list of CultureInfo codes.

Exceptions:
  • System.ArgumentException
  • SetCultureInfo will throw this exception if the CultureInfo object passed to it is invariant (an empty string) or neutral (for example "en" rather than "en-US" or "en-AU"). The CultureInfo passed to SetCultureInfo must include both language and country (for example "fr-BE" for French-Belgium).

  • System.Security.SecurityException
    If you pass null to SetCultureInfo, WordWriter sets the Word file's CultureInfo to the system's default CultureInfo. If system security denies access to the system's default CultureInfo, SetCultureInfo(null) will throw a SecurityException.
Examples:
	[VB.NET]
	'--- The CultureInfo class is in the System.Globalization
	'--- namespace.  Import this namespace to the aspx page.
	<%@ Import Namespace="System.Globalization" %>
	
	...
	
	'--- Create an instance of the WordWriter object.
	oWW = New WordTemplate()
	
	'--- Declare a CultureInfo object and set it to 
	'--- US English.	
	Dim enUS As New CultureInfo("en-US", False)
	
	'--- Pass the US English CultureInfo object to the
	'--- SetCultureInfo method.
	oWW.SetCultureInfo(enUS)

	'--- Call Open() to open the template file.
	oWW.Open(Server.MapPath("./FormattingTemplate.doc"))
	
	'--- Set the template's data source.
	oWW.SetDataSource(arrValue, arrName)

	'--- Call Process() to populate the template with 
	'--- the new data.
	oWW.Process()

	'--- After processing the template, call Save() and pass it 
	'--- Page.Response to stream the generated file to the browser.
	oWW.Save(Page.Response, "FormattingOutput.doc", False)

ASP.NET Reference: WordTemplate Object Open SetCultureInfo SetDataSource GetVersion Process Save
ASP Reference: WordTemplate Object Open SetCultureInfo SetDataSource GetVersion Process Save


Copyright © 2003, SoftArtisans, Inc.