一、
我有同样问题,添加引用后出现警告,但安装试用版没问题, 当前的目标框架“.NETFramework,Version=v4.0,Profile=Client”未包含引用的程序集“Aspose.Words, Version=11.7.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56, processorArchitecture=MSIL”所依赖的“System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”。
这会导致无法解析引用的程序集。若要解决此问题,请 (1) 更改此项目的目标框架,或者 (2) 从此项目中删除引用的程序集。
二、谁有或用过Aspose.Words for NET操作word的详细实例
嗯,现在在使用中 用的Aspose.Words
但是HTML标记会直接输出在word里。
C# code
?
1
2
3
4
5
6
7
8
9
10
//建立Document物件
Document doc = new Document();
//建立DocumentBuilder物件
DocumentBuilder builder = new DocumentBuilder(doc);
//新增文字
builder.Writeln(txtinfo.Value.Trim());
//将上述设定的格式清除
builder.Font.ClearFormatting();
//将文件存档
doc.Save("D://Test.doc");
HTML格式的化,应该用什么方法接收txtinfo的值来转化呢。。您知道么。
三、如何使用Aspose Words for Java插入条形图
虽然Aspose.Words for Java目前还不允许在Word文档中创建条形图。但是可以通过Aspose.Cells for Java创建静态条形图,并选染成图片,然后再通过Aspose.Words for Java添加到Word文档中:
//Create a new Workbook.
Workbook workbook = new Workbook();
//Get the first worksheet.
Worksheet sheet = workbook.getWorksheets().get(0);
//Set the name of worksheet
sheet.setName("Data");
//Get the cells collection in the sheet.
Cells cells = workbook.getWorksheets().get(0).getCells();
//Put some values into a cells of the Data sheet.
cells.get("A1").setValue("Region");
cells.get("A2").setValue("France");
cells.get("A3").setValue("Germany");
cells.get("A4").setValue("England");
四、如何使用Aspose.Words在邮件合并时生成多个文档
产生多个文档需要进行多次邮件合并。
如果需要将数据源中的所有数据都存在于一个单独的文件中,需要做到以下几点: 循环数据表中的所有行。 在邮件合并前载入(或复制)原始文档。
执行邮件合并,保存文件。 你可以在每个邮件合并前从一个文件或流中加载模板文件,但通常情况下,更为快速的方法是只加载一次文档,然后在每次邮件合并前从内存中复制。
要注意的是,执行邮件合并你应该有一个适当的模板文件。这个模板可以是一个Microsoft Word模板或一个普通的Microsoft Word文档,但它需要在插入数据的地方包含MERGEFIELD字段。
每个字段的名称应和数据源中相应的字段相同。 C# using System; using System.Data; using System.Data.OleDb; using System.IO; using System.Reflection; using Aspose.Words; namespace MultipleDocsInMailMerge { 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; ProduceMultipleDocuments(dataDir, "TestFile.doc"); } public static void ProduceMultipleDocuments(string dataDir, string srcDoc) { // Open the database connection. string connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dataDir + "Customers.mdb"; OleDbConnection conn = new OleDbConnection(connString); conn.Open(); try { // Get data from a database. OleDbCommand cmd = new OleDbCommand("SELECT * FROM Customers", conn); OleDbDataAdapter da = new OleDbDataAdapter(cmd); DataTable data = new DataTable(); da.Fill(data); // Open the template document. Document doc = new Document(dataDir + srcDoc); int counter = 1; // Loop though all records in the data source. foreach (DataRow row in data.Rows) { // Clone the template instead of loading it from disk (for speed). Document dstDoc = (Document)doc.Clone(true); // Execute mail merge. dstDoc.MailMerge.Execute(row); // Save the document. dstDoc.Save(string.Format(dataDir + "TestFile Out {0}.doc", counter++)); } } finally { // Close the database. conn.Close(); } } } } VB Imports Microsoft.VisualBasic Imports System Imports System.Data Imports System.Data.OleDb Imports System.IO Imports System.Reflection Imports Aspose.Words Namespace MultipleDocsInMailMerge 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 ProduceMultipleDocuments(dataDir, "TestFile.doc") End Sub Public Shared Sub ProduceMultipleDocuments(ByVal dataDir As String, ByVal srcDoc As String) ' Open the database connection. Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dataDir & "Customers.mdb" Dim conn As New OleDbConnection(connString) conn.Open() Try ' Get data from a database. Dim cmd As New OleDbCommand("SELECT * FROM Customers", conn) Dim da As New OleDbDataAdapter(cmd) Dim data As New DataTable() da.Fill(data) ' Open the template document. Dim doc As New Document(dataDir & srcDoc) Dim counter As Integer = 1 ' Loop though all records in the data source. For Each row As DataRow In data.Rows ' Clone the template instead of loading it from disk (for speed). Dim dstDoc As Document = CType(doc.Clone(True), Document) ' Execute mail merge. dstDoc.MailMerge.Execute(row) ' Save the document. dstDoc.Save(String.Format(dataDir & "TestFile Out {0}.doc", counter)) counter += 1 Next row Finally ' Close the database. conn.Close() End Try End Sub End Class End Namespace。
五、请问如何使用Aspose.Words将文件转换为MHTML和Email
C# // Load the document into Aspose.Words. string srcFileName = Path.Combine(dataDir, "DinnerInvitationDemo.doc"); Document doc = new Document(srcFileName); // Save into a memory stream in MHTML format. Stream stream = new MemoryStream(); doc.Save(stream, SaveFormat.Mhtml); // Rewind the stream to the beginning so Aspose.Network can read it. stream.Position = 0; // Create an Aspose.Network MIME email message from the stream. MailMessage message = MailMessage.Load(stream, MessageFormat.Mht); message.From = "your_from@email.com"; message.To = "your_to@email.com"; message.Subject = "Aspose.Words + Aspose.Network MHTML Test Message"; // Send the message using Aspose.Network SmtpClient client = new SmtpClient(); client.Host = "your_smtp.com"; client.AuthenticationMethod = SmtpAuthentication.None; client.Send(message); VB ' Load the document into Aspose.Words. Dim srcFileName As String = Path.Combine(dataDir, "DinnerInvitationDemo.doc") Dim doc As New Document(srcFileName) ' Save into a memory stream in MHTML format. Dim stream As Stream = New MemoryStream() doc.Save(stream, SaveFormat.Mhtml) ' Rewind the stream to the beginning so Aspose.Network can read it. stream.Position = 0 ' Create an Aspose.Network MIME email message from the stream. Dim message As MailMessage = MailMessage.Load(stream, MessageFormat.Mht) message.From = "your_from@email.com" message.To = "your_to@email.com" message.Subject = "Aspose.Words + Aspose.Network MHTML Test Message" ' Send the message using Aspose.Network Dim client As New SmtpClient() client.Host = "your_smtp.com" client.AuthenticationMethod = SmtpAuthentication.None client.Send(message)。
六、如何破解aspose.words
直接用破解版就看了
1、将压缩包内文件夹o16_x86和o16_x64都解压出来;
PS:两个文件夹都为必要文件,若是缺少一个文件夹会导致无法安装。
2、打开其中的o16_x86文件夹点击setup.cmd;
3、自动弹出cmd弹窗后,进入下载安装;
PS:请耐心等待,不要关闭计算机,直至安装完成。
4、安装完成后打开“开始”菜单中找到Microsoft Office 2016 Previe;
5、选中需要的软件打开即可使用,无需其他操作。
Office 2016 :http://www.3322.cc/soft/201508211622.html
转载请注明出处51数据库 » aspose.words使用