public FileInfo GenerateBankFileExcel() { if (BankFileDetails.Count > 0) { FileInfo result = GenerateTempFileName(); string exportFileName = result.FullName; result.Delete(); //System.IO.File.Copy(Server.MapPath("~/template/HistoryList_Template.xls"), exportFileName, true); HROne.Export.ExcelExport export = new HROne.Export.ExcelExport(exportFileName); System.Data.DataSet dataSet = new System.Data.DataSet();//export.GetDataSet(); DataTable dataTable = new DataTable("BankFile$"); dataSet.Tables.Add(dataTable); dataTable.Columns.Add("Product Code", typeof(string)); dataTable.Columns.Add("Debit Acct Country Code", typeof(string)); dataTable.Columns.Add("Debit Acct Number", typeof(string)); dataTable.Columns.Add("Payment Currency", typeof(string)); dataTable.Columns.Add("Payment Amount", typeof(double)); dataTable.Columns.Add("Value Date", typeof(string)); dataTable.Columns.Add("Transacation Reference Num", typeof(string)); dataTable.Columns.Add("Ordering Party Name", typeof(string)); dataTable.Columns.Add("Beneficiary Name", typeof(string)); dataTable.Columns.Add("Beneficiary Account", typeof(string)); dataTable.Columns.Add("Payment Details", typeof(string)); foreach (GenericBankFileDetail bankFileDetail in BankFileDetails) { DataRow row = dataTable.NewRow(); if (string.IsNullOrEmpty(ProductCode) && !bankFileDetail.IsChequePayment) { continue; } if (bankFileDetail.IsChequePayment) { row["Product Code"] = "PLC"; row["Beneficiary Name"] = bankFileDetail.EmpName; row["Beneficiary Account"] = string.Empty; } else { row["Product Code"] = m_ProductCode; row["Beneficiary Name"] = bankFileDetail.EmpBankAccountHolderName.PadRight(70).Substring(0, 70).Trim(); row["Beneficiary Account"] = bankFileDetail.BankCode.PadRight(3).Substring(0, 3) + "-" + bankFileDetail.BranchCode.PadRight(3).Substring(0, 3) + "-" + bankFileDetail.AccountNo; } row["Debit Acct Country Code"] = "HK"; row["Debit Acct Number"] = m_BranchCode + m_AccountNo; row["Payment Currency"] = "HKD"; row["Payment Amount"] = bankFileDetail.Amount; row["Value Date"] = m_ValueDate.ToString("yyyyMMdd"); row["Transacation Reference Num"] = bankFileDetail.EmpNo.PadRight(15).Substring(0, 15).Trim(); row["Ordering Party Name"] = m_AccountHolderName; row["Payment Details"] = m_PaymentDetails; dataTable.Rows.Add(row); } export.Update(dataSet); return(result); } else { return(null); } }