using DevExpress.Spreadsheet; using DevExpress.XtraEditors; using System; using System.Collections.Generic; using System.ComponentModel; using System.Configuration; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Gs.DevApp.UserControl { public partial class CopyXls : DevExpress.XtraEditors.XtraForm { private string orderType; private string orderGuid; private static readonly string filePath = AppContext.BaseDirectory + "xlsCopy.xls"; public CopyXls(string orgId, string _orderGuid, string _orderType) { InitializeComponent(); this.Text = "正在复制:" + _orderType; this.orderType = _orderType; this.orderGuid = _orderGuid; this.spreadsheetControl1.DocumentLoaded += new EventHandler(spreadsheetControl1_DocumentLoaded); if (!string.IsNullOrEmpty(filePath)) { if (File.Exists(filePath)) { IWorkbook workbook = spreadsheetControl1.Document; workbook.LoadDocument(filePath); } else { Gs.DevApp.ToolBox.MsgHelper.ShowError("找不到xlsCopy.xls文件,请联系管理员!"); } } } /// /// 文档变化后,实现对新文件名称的显示 /// void spreadsheetControl1_DocumentLoaded(object sender, EventArgs e) { string fileName = Path.GetFileName(this.spreadsheetControl1.Document.Path); if (String.IsNullOrEmpty(fileName)) { Text = "请选择文件"; } else { Text = fileName; } } /// /// 保存 /// /// /// private void btnSave_Click(object sender, EventArgs e) { spreadsheetControl1.SaveDocument(); } } }