protected void cmdLoadCheckResult_click(object sender, EventArgs e) { if (_WarehouseFacade == null) { _WarehouseFacade = new BenQGuru.eMES.Material.WarehouseFacade(base.DataProvider); } ArrayList array = this.gridHelper.GetCheckedRows(); if (array == null) { return; } if (array.Count != 1) { WebInfoPublish.Publish(this, "只能选择一行!", this.languageComponent1); return; } string time = DateTime.Now.ToString("yyyyMMdd_HHmmss");//")+ ""+DateTime.Now.ToString(" XlsPackage xls = new XlsPackage(); string filename = string.Format("Export_{0}_{1}.{2}", FormatHelper.TODateInt(System.DateTime.Now).ToString(), FormatHelper.TOTimeInt(System.DateTime.Now).ToString(), "xls"); string filepath = string.Format(@"{0}{1}", this.DownloadPhysicalPath, filename); int n = 1; foreach (GridRecord row1 in array) { string checkNo = row1.Items.FindItemByKey("CheckNo").Text; xls.CreateSheet("sheet" + n); xls.NewRow(0); xls.Cell(0, "盘点单号:", xls.Normal); xls.Cell(1, checkNo, xls.Normal); xls.NewRow(1); xls.Cell(0, "库位", xls.Normal); xls.Cell(1, "鼎桥物料编码", xls.Normal); xls.Cell(2, "盘点数量", xls.Normal); BenQGuru.eMES.Domain.Warehouse.StockCheck ssss = (BenQGuru.eMES.Domain.Warehouse.StockCheck)_WarehouseFacade.GetStockCheck(checkNo); if (ssss.CheckType != "All") { WebInfoPublish.Publish(this, "必须是全盘才可用!", this.languageComponent1); return; } int i = 1; BenQGuru.eMES.Domain.Warehouse.StockCheckDetail[] sdddd = _WarehouseFacade.GetDisStockCheckDetails(checkNo); foreach (BenQGuru.eMES.Domain.Warehouse.StockCheckDetail d in sdddd) { xls.NewRow(1 + i); xls.Cell(0, d.StorageCode, xls.Normal); xls.Cell(1, d.DQMCODE, xls.Normal); xls.Cell(2, d.CheckQty.ToString(), xls.Normal); i++; } n++; } System.IO.FileStream file = new System.IO.FileStream(filepath, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite); xls.Save(file); file.Close(); DownLoadFile1(filename); }