using System;
using System.Collections;
using System.Collections.Generic;
namespace DPExample
{
public class Resume : ICloneable
{
private string name;
private string sex;
private string age;
private WorkExperience work;
public Resume(string name)
{
this.name = name;
this.work = new WorkExperience();
}
public Resume (WorkExperience work)
{
this.work = (WorkExperience)work.Clone();
}
public void SetPersonalProfile(string sex, string age)
{
this.sex = sex;
this.age = age;
}
public void SetWorkExperience(string timeArea, string company)
{
work.Time = timeArea;
work.Company = company;
}
public void Display()
{
Console.WriteLine ("{0} {1} {2}", name, sex,age );
Console.WriteLine ("Work Experience: {0} {1}", work.Time, work.Company);
}
public Object Clone()
{
Resume obj = new Resume(this.work);
obj.name = this.name;
obj.sex = this.sex;
obj.age = this.age;
return obj;
}
}
public class WorkExperience : ICloneable
{
private string time;
private string company;
public string Time { get { return time; } set { time = value; }}
public string Company { get { return company; } set { company = value; } }
public Object Clone()
{
return (Object)this.MemberwiseClone();
}
}
}
前由 我有全區的電話資料,問題在於我要依不同里別來製作出電話簿。結果如下圖: 單純採用合併列印無法達成我的需求。解決方法係用「功能變數」儲存上一個里別,與現在里別進行比較:若不同,則換頁。不過,這樣功能變數還蠻長的。最後,我還是採用 C# 來解決。 解決方案 用 C# 控制 WORD 中合併列印的「資料來源 Data Source」,給予不同里別的「sqlstatement」。迴圈處理不同的里別即可。但可預見其處理過程會很慢,不過還好,我可以不用在意它,有跑出結果即可。 程式碼 IList<string> areas = new List<string>() { "後壁", "侯伯", "嘉苳", "土溝", "嘉田", "嘉民", "菁豊", "崁頂", "後廍", "墨林", "菁寮", "新嘉", "頂長", "平安", "仕安", "竹新", "新東", "長安", "頂安", "福安", "烏樹" }; string root = @"D:\"; // 根目錄 string data = root + @"\data.docm"; // 資料檔(即資料來源) string template = root + @"\template.docx"; // 已設定好格式與合併欄位的 Word 檔 string output = @"d:\Final"; // 輸出之資料夾 object oMissing = System.Reflection.Missing.Va...

留言
張貼留言