
如何使用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.word 如何删除页眉
删除页眉的方法:打开Word文档后,点击上方的“视图(V)”菜单——>;选择“页眉和页脚(H)”——>;进入页眉编辑状态,并弹出页眉工具菜单,全选中页眉内容(按下Ctrl+A全选)后,点击“Delete键”删除内容——>;删除内容后,点击“页眉页脚”菜单中的“关闭(C)”即可;
删除页脚的方法:仍然是点击“视图(V)”菜单——>;选择“页眉页脚(H)”——>;此时将弹出“页眉页脚”菜单栏——>;点击“关闭(C)”左边的第三个按钮“在页眉和页脚间切换”,然后切换到“页脚”编辑状态——>;全选“页脚”内容,按“Delete”删除即可;
经验总结:双击文档里的页眉或页脚,就可以进入页眉页脚的编辑状态,可以再次编辑,改变页眉页脚的样子。在编辑状态将页眉页脚里的内容全部删除,然后操作菜单“格式”→“样式和格式”,点选“样式和格式”里的“清除格式”,最后点击“页眉和页脚”工具条里的“关闭”,退出编辑后页眉和页脚就被彻底删除了。
如何使用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。
英语作文Mylastweek end
Last Weekend
I had a happy weekend last week.
On Saturday morning,I watched TV and helped my mother wash clothes.In the afternoon,I cleaned three bedrooms in my house-- mine,my parents' and my brother's.
On Sunday,I played football in the park.Then I went to my grandparents' house.Grandpa played the piano!The whole family was so happy.Later,we wanted to swim.But it was too cold.
This was my last weekend
高晓松说“ 不要温和地走进那个良夜 ”翻译错了,对吗
《不要温和地走进那个良夜》是英国诗人狄兰·托马斯创作于20世纪中期的诗歌,该诗歌表达了诗人对于死神将可爱的人们带离这个世界表达了愤怒,即“怒斥光明的消逝”。
《不要温和地走进那个良夜》作于诗人的父亲逝世前的病危期间,整首诗充斥着夜晚与白昼、黑暗与光明、温和与狂暴、死亡与生命的二元对立,因此语言的张力十分饱满。
诗歌原文
Do not go gentle into that good night,
Old age should burn and rave at close of day;
Rage, rage against the dying of the light.
Though wise men at their end know dark is right,
Because their words had forked no lightning they
Do not go gentle into that good night.
Good men, the last wave by, crying how bright
Their frail deeds might have danced in a green bay,
Rage, rage against the dying of the light.
Wild men who caught and sang the sun in flight,
And learn, too late, they grieved it on its way,
Do not go gentle into that good night.
Grave men, near death, who see with blinding sight
Blind eyes could blaze like meteors and be gay,
Rage, rage against the dying of the light.
And you, my father, there on the sad height,
Curse, bless me now with your fierce tears, I pray.
Do not go gentle into that good night.
Rage, rage against the dying of the light.
中文翻译
翻译:巫宁坤
不要温和地走进那个良夜,
老年应当在日暮时燃烧咆哮;
怒斥,怒斥光明的消逝。
虽然智慧的人临终时懂得黑暗有理,
因为他们的话没有迸发出闪电,他们
也并不温和地走进那个良夜。
善良的人,当最后一浪过去,高呼他们脆弱的善行
可能曾会多么光辉地在绿色的海湾里舞蹈,
怒斥,怒斥光明的消逝。
狂暴的人抓住并歌唱过翱翔的太阳,
懂得,但为时太晚,他们使太阳在途中悲伤,
也并不温和地走进那个良夜。
严肃的人,接近死亡,用炫目的视觉看出
失明的眼睛可以像流星一样闪耀欢欣,
怒斥,怒斥光明的消逝。
您啊,我的父亲.在那悲哀的高处.
现在用您的热泪诅咒我,祝福我吧.我求您
不要温和地走进那个良夜。
怒斥,怒斥光明的消逝。
奥黛丽赫本对她女儿说过,要想拥有美丽的眼睛
赫本曾向人透露她的美丽秘诀:
要想拥有吸引人的双唇,请说善意的言语;
要拥有美丽的眼睛,请寻找他人的优点;
要想拥有纤细的身材,请与饥饿的人分享你的食物;
要拥有亮丽的头发,请让小孩子每日触摸你的头发;
要想拥有自信的态度,请学习你不曾学过的知识。
她没有孩子
英文的?
For attractive lips, speak words of kindness.
若要优美的嘴唇,要说友善的话;
For lovely eyes, seek out the good in people.
若要可爱的眼睛,要看到别人的好处;
For a slim figure, share your foodwith the hungry.
若要苗条的身材,把你的食物分给饥饿的人;
For beautiful hair, let a child run his or her fingers through it once a day.
美丽的秀发,在于每天有孩子的手指穿过它;
For poise, walk with the knowledge that you never walk alone.
若要优雅的姿态,要记住行人不只你一个。
People, even more than things, have to be restored, revived, reclaimed and redeemed; never throw out anyone.
人之所以为人,是应该充满精力、能够自我悔改、自我反省、自我成长,而不是抱怨他人。
Remember, if you ever need a helping hand, you'll find them at the end of each of your arms. As you grow older, you will discover that you have two hands, one for helping yourself, the other for helping others.
如果你需要一只援助之手,你可以在自己的任何一只手臂下找到;随着年龄的增长,你会发现你有两只手,一只用来帮助自己,另一只用来帮助别人。
转载请注明出处51数据库 » aspose.wordsendtabl
Personalitycha