public virtual void Importxls(string filename, Hashtable dict) { office.PubExcel el = new office.PubExcel(filename, "sheet1"); el.Visible = true; el.ImportXls(dt); el.closeExcel(); }
public void Exportxls(String filename, Hashtable dict) { if (dt.Columns.Count > 127) { MessageBox.Show("欄位過長,超過127,現在欄位為" + dt.Columns.Count); return; } bool datetimefield_Str_flag = true; for (int i = 0; i < dt.Columns.Count; i++) { if (dt.Columns[i].DataType.Equals(System.Type.GetType("System.DateTime"))) { if (MessageBox.Show("日期欄位匯出時文字表示,是; 否則用數字表示", "日期欄位", MessageBoxButtons.YesNo) == DialogResult.No) { datetimefield_Str_flag = false; } } } office.PubExcel el = new office.PubExcel(datetimefield_Str_flag); el.Visible = true; el.ExportXls(dt, dict); el.saveTo(filename, true); el.closeExcel(); }