亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

C#如何更改Word的語言設置

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

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

代碼操作前準備

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

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

具體步驟如下:

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

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

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

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

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

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

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

//添加文檔屬性(內(nèi)置屬性)
doc.BuiltinDocumentProperties.Title = "測試文件";
doc.BuiltinDocumentProperties.Category = "非機密文檔";
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");

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

對文檔屬性的設置如下圖所示:

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

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

相關文章

最新評論