原創|其它|編輯:郝浩|2012-10-19 17:13:08.000|閱讀 522 次
概述:Aspose.Words允許導入純文本數據,但是需要通過通過使用Document constructor文檔構造函數。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Aspose.Words允許導入純文本數據,但是需要通過通過使用Document constructor文檔構造函數。
純文本格式是一個基本的格式,不需要先進的文本處理器查看或編輯。然而一些純文本文件中含有更復雜的格式(如列表和縮進)。Aspose.Words檢測和負載這樣的特性到一個新的文檔,就可以將文本文檔等效為Microsoft word。
C#
using System; using System.IO; using System.Reflection; using System.Text; using Aspose.Words; namespace LoadTxt { class Program { public static void Main(string[] args) { // Sample infrastructure. string exeDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar; string dataDir = new Uri(new Uri(exeDir), @"../../Data/").LocalPath; // The encoding of the text file is automatically detected. Document doc = new Document(dataDir + "LoadTxt.txt"); // Save as any Aspose.Words supported format, such as DOCX. doc.Save(dataDir + "LoadTxt Out.docx"); } } }
Visual Basic
Imports Microsoft.VisualBasic Imports System Imports System.IO Imports System.Reflection Imports System.Text Imports Aspose.Words Namespace LoadTxt Friend Class Program Public Shared Sub Main(ByVal args() As String) ' Sample infrastructure. Dim exeDir As String = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar Dim dataDir As String = New Uri(New Uri(exeDir), "../../Data/").LocalPath ' The encoding of the text file is automatically detected. Dim doc As New Document(dataDir & "LoadTxt.txt") ' Save as any Aspose.Words supported format, such as DOCX. doc.Save(dataDir & "LoadTxt Out.docx") End Sub End Class End Namespace
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網