原創(chuàng)|其它|編輯:郝浩|2012-10-19 17:13:08.000|閱讀 522 次
概述:Aspose.Words允許導(dǎo)入純文本數(shù)據(jù),但是需要通過通過使用Document constructor文檔構(gòu)造函數(shù)。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Aspose.Words允許導(dǎo)入純文本數(shù)據(jù),但是需要通過通過使用Document constructor文檔構(gòu)造函數(shù)。
純文本格式是一個基本的格式,不需要先進(jìn)的文本處理器查看或編輯。然而一些純文本文件中含有更復(fù)雜的格式(如列表和縮進(jìn))。Aspose.Words檢測和負(fù)載這樣的特性到一個新的文檔,就可以將文本文檔等效為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
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)