C # how to change the Word language input settings,
When creating or opening a Word document, if no special settings have been made, the default input language of the system is English, but to adapt to different office environments, we actually need to switch the language of the text embedded, so this article will introduce how to use the free version of componentsFree Spire. Doc for. NETTo implement Word language input. In addition, this article will further demonstrate the various Word operation functions for this component, such as setting document attributes and document view modes.
Prepare for code operation
After installing Spire. Doc for. NET, add the file referencing Spire. Doc. dll to the project assembly and add the corresponding using command to the namespace.
Note:: In the following code, select Spanish (Peru) as an example. For other language settings, seeMicrosoft Locale ID Values
The procedure is as follows:
Step 1: Add the following namespace
using System;using Spire.Doc;using Spire.Doc.Documents;using Spire.Doc.Fields;
Step 2: Change the text input language
// Create a Document class instance and add Section and Paragraph to DocumentDocument doc = new Document (); Section sec = doc. addSection (); Paragraph para = sec. addParagraph (); // Add Spanish (Peru) Chinese characters to the paragraph and set text alignment mode TextRange txtRange = para. appendText ("Puedo escribir los versos más tristes esta noche. \ n Escribir, por ejemplo: La noche est áestrellada, y tiritan, azules, los astros, a lo lejos. \ n El viento de la noche gira en el cielo y canta. \ n Puedo escribir los versos más tristes esta noche. "); txtRange. characterFormat. localeIdASCII = 10250; para. format. horizontalAlignment = HorizontalAlignment. center;
Step 3: Set the attempt mode to Web View and adjust the zoom ratio of View
doc.ViewSetup.DocumentViewType = DocumentViewType.WebLayout;doc.ViewSetup.ZoomPercent = 120;doc.ViewSetup.ZoomType = ZoomType.None;
Step 4: Add document attributes (you can set the built-in or custom attributes of the document as needed)
// Add document attributes (built-in attributes) doc. builtinDocumentProperties. title = "test file"; doc. builtinDocumentProperties. category = "non-confidential document"; doc. builtinDocumentProperties. author = "James"; doc. builtinDocumentProperties. lastAuthor = "Mia"; doc. builtinDocumentProperties. keywords = "Word documents, attributes, samples"; doc. builtinDocumentProperties. comments = "This document is for testing only"; doc. builtinDocumentProperties. subject = "Demo"; // Add document attributes (custom attributes) CustomDocumentProperties custom = doc. customDocumentProperties; custom. add ("Authorized Date", DateTime. today );
Step 5: Save and open the document
doc.SaveToFile("Sample.doc", FileFormat.Doc);System.Diagnostics.Process.Start("Sample.doc");
After completing the preceding steps, run the project generation file (you can view it in bin> Debug under the project folder), as shown in:
Shows how to set document attributes:
All of the above is a description of the language setting method for the Word document. The document attribute setting is also helpful in saving the document and managing the document in the future. I hope this article will provide some help. You are welcome to repost it (please indicate the source for reprinting ). Thank you for browsing!