欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#如何更改Word的語言設(shè)置

 更新時間:2018年05月17日 11:59:16   作者:E-iceblue  
這篇文章主要為大家詳細(xì)介紹了C#如何更改Word的語言設(shè)置,具有一定的參考價值,感興趣的小伙伴們可以參考一下

一般在創(chuàng)建或者打開一個Word文檔時,如果沒有進(jìn)行過特殊設(shè)置的話,系統(tǒng)默認(rèn)的輸入語言的是英語輸入,但是為適應(yīng)不同的辦公環(huán)境,我們其實(shí)是需要對文字嵌入的語言進(jìn)行切換的,因此,本文將介紹如何使用免費(fèi)版組件Free Spire.Doc for .NET來實(shí)現(xiàn)Word語言輸入。另外,針對這款組件的多種Word操作功能,如,設(shè)置文檔屬性、文檔視圖模式等,本文中也將作進(jìn)一步演示演示。

代碼操作前準(zhǔn)備

安裝Spire.Doc for .NET之后,添加引用Spire.Doc.dll文件到項(xiàng)目程序集,同時添加相應(yīng)的using指令到命名空間。

注意:以下代碼中,以選取西班牙語(秘魯)為例,其他語言設(shè)置,可參見 Microsoft Locale ID Values

具體步驟如下:

步驟一:添加如下命名空間

using System;
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;

步驟二:更改文本輸入語言

//創(chuàng)建一個Document類實(shí)例,并添加Section和Paragraph到Document
Document doc = new Document();
Section sec = doc.AddSection();
Paragraph para = sec.AddParagraph();
//向段落添加西班牙(秘魯)語文字并設(shè)置文本對齊方式
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;

步驟三:設(shè)置試圖模式為Web視圖,調(diào)整視圖縮放比例

doc.ViewSetup.DocumentViewType = DocumentViewType.WebLayout;
doc.ViewSetup.ZoomPercent = 120;
doc.ViewSetup.ZoomType = ZoomType.None;

步驟四:添加文檔屬性(可根據(jù)需要自行設(shè)置文檔內(nèi)置屬性或者自定義屬性)

//添加文檔屬性(內(nèi)置屬性)
doc.BuiltinDocumentProperties.Title = "測試文件";
doc.BuiltinDocumentProperties.Category = "非機(jī)密文檔";
doc.BuiltinDocumentProperties.Author = "James";
doc.BuiltinDocumentProperties.LastAuthor = "Mia";
doc.BuiltinDocumentProperties.Keywords = "Word文檔, 屬性, 樣本";
doc.BuiltinDocumentProperties.Comments = "此文檔僅供測試使用";
doc.BuiltinDocumentProperties.Subject = "Demo";

//添加文檔屬性(自定義屬性)
CustomDocumentProperties custom = doc.CustomDocumentProperties;
custom.Add("Authorized Date", DateTime.Today);

步驟五:保存并打開文檔

doc.SaveToFile("Sample.doc", FileFormat.Doc);
System.Diagnostics.Process.Start("Sample.doc");

完成以上步驟后,運(yùn)行該項(xiàng)目生成文件(可在該項(xiàng)目文件夾下bin>Debug下查看),如下圖所示:

對文檔屬性的設(shè)置如下圖所示:

以上全部內(nèi)容為本次對Word文檔進(jìn)行語言設(shè)置方法的講述,文中對文檔的屬性設(shè)置在文檔的保存與日后文檔管理上其實(shí)也很有幫助。希望本文能提供一定幫助,感謝瀏覽!

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論