示例#1
0
        public string CheckExeclValid(ExcelWorksheet worksheet, int iRow, int FlowChart_Master_UID, FlowChartExcelImportParas paraItem, out string Part_Types)
        {
            Part_Types = string.Empty;
            string errorInfo = string.Empty;

            if (worksheet == null)
            {
                errorInfo = "没有worksheet内容";

                return(errorInfo);
            }
            //头样式设置
            var propertiesHead = FlowchartImportCommon.GetHeadColumn();

            bool allColumnsAreEmpty = true;

            for (var i = 1; i <= propertiesHead.Length; i++)
            {
                if (worksheet.Cells[iRow, i].Value != null && !String.IsNullOrEmpty(worksheet.Cells[iRow, i].Value.ToString()))
                {
                    allColumnsAreEmpty = false;
                    break;
                }
            }
            if (allColumnsAreEmpty)
            {
                errorInfo = "Excel格式不正确";
                return(errorInfo);
            }

            string BU_D_Name    = ExcelHelper.ConvertColumnToString(worksheet.Cells[iRow, ExcelHelper.GetColumnIndex(propertiesHead, "客户")].Value);
            string Project_Name = ExcelHelper.ConvertColumnToString(worksheet.Cells[iRow, ExcelHelper.GetColumnIndex(propertiesHead, "专案名称")].Value);

            Part_Types = ExcelHelper.ConvertColumnToString(worksheet.Cells[iRow, ExcelHelper.GetColumnIndex(propertiesHead, "部件")].Value);
            string Product_Phase = ExcelHelper.ConvertColumnToString(worksheet.Cells[iRow, ExcelHelper.GetColumnIndex(propertiesHead, "阶段")].Value);

            if (string.IsNullOrWhiteSpace(BU_D_Name) || string.IsNullOrWhiteSpace(Project_Name) || string.IsNullOrWhiteSpace(Part_Types) || string.IsNullOrWhiteSpace(Product_Phase))
            {
                errorInfo = "客户,专案名称,部件,阶段不能为空Excel格式不正确";
                return(errorInfo);
            }

            paraItem.BU_D_Name            = BU_D_Name.Trim();
            paraItem.Project_Name         = Project_Name.Trim();
            paraItem.Part_Types           = Part_Types.Trim();
            paraItem.Product_Phase        = Product_Phase.Trim();
            paraItem.FlowChart_Master_UID = FlowChart_Master_UID;
            return(errorInfo);
        }
示例#2
0
        public override ActionResult DoHistoryExcelExport(int id, int version)
        {
            var apiUrl        = string.Format("FlowChart/DoHistoryExcelExportWUXI_MAPI?id={0}&version={1}", id, version);
            var responMessage = APIHelper.APIGetAsync(apiUrl);
            var result        = responMessage.Content.ReadAsStringAsync().Result;
            var item          = JsonConvert.DeserializeObject <FlowChartExcelExport>(result);



            var stream            = new MemoryStream();
            var fileName          = PathHelper.SetGridExportExcelName("FlowChart");
            var filePath          = Path.Combine(PathHelper.GetGridExportExcelDirectory, fileName);
            var propertiesHead    = FlowchartImportCommon.GetHeadColumn();
            var propertiesContent = FlowchartImportCommon.GetEtransferContentColumn();

            using (var excelPackage = new ExcelPackage(stream))
            {
                //set sheet name
                var worksheet = excelPackage.Workbook.Worksheets.Add("FlowChart");

                //填充Title内容
                for (int colIndex = 0; colIndex < propertiesHead.Length; colIndex++)
                {
                    worksheet.Cells[1, colIndex + 1].Value = propertiesHead[colIndex];

                    switch (colIndex)
                    {
                    case 0:
                        worksheet.Cells[2, colIndex + 1].Value = item.BU_D_Name;
                        break;

                    case 1:
                        worksheet.Cells[2, colIndex + 1].Value = item.Project_Name;
                        break;

                    case 2:
                        worksheet.Cells[2, colIndex + 1].Value = item.Part_Types;
                        break;

                    case 3:
                        worksheet.Cells[2, colIndex + 1].Value = item.Product_Phase;
                        break;
                    }
                }

                //填充Content内容
                for (int colIndex = 0; colIndex < propertiesContent.Length; colIndex++)
                {
                    worksheet.Cells[3, colIndex + 1].Value = propertiesContent[colIndex];
                }

                for (int index = 0; index < item.FlowChartDetailAndMGDataDTOList.Count(); index++)
                {
                    var currentRecord = item.FlowChartDetailAndMGDataDTOList[index];
                    //绑定序号
                    worksheet.Cells[index + 4, 1].Value = currentRecord.Binding_Seq;
                    //制程序号
                    worksheet.Cells[index + 4, 2].Value = currentRecord.ItemNo;
                    //DRI
                    worksheet.Cells[index + 4, 3].Value = currentRecord.DRI;
                    //场地
                    worksheet.Cells[index + 4, 4].Value = currentRecord.Place;
                    //Process
                    worksheet.Cells[index + 4, 5].Value = currentRecord.Process;
                    //厂别
                    worksheet.Cells[index + 4, 6].Value = currentRecord.PlantName;
                    //阶层
                    worksheet.Cells[index + 4, 7].Value = currentRecord.Product_Stage;
                    //颜色
                    worksheet.Cells[index + 4, 8].Value = currentRecord.Color;
                    //Edition
                    worksheet.Cells[index + 4, 9].Value = currentRecord.Edition;
                    //工站说明
                    worksheet.Cells[index + 4, 10].Value = currentRecord.Process_Desc;
                    //返工设定
                    worksheet.Cells[index + 4, 11].Value = currentRecord.Rework_Flag;
                    //检测设定
                    worksheet.Cells[index + 4, 12].Value = currentRecord.IsQAProcessName;
                    //FromWHS
                    worksheet.Cells[index + 4, 13].Value = currentRecord.FromWHS;
                    //ToWHSOK
                    worksheet.Cells[index + 4, 14].Value = currentRecord.ToWHSOK;
                    //ToWHSNG
                    worksheet.Cells[index + 4, 15].Value = currentRecord.ToWHSNG;

                    //目标良率
                    //worksheet.Cells[index + 4, 9].Value = currentRecord.Target_Yield;
                    //worksheet.Cells[index + 4, 9].Style.Numberformat.Format = "0.00%";
                    //计划目标
                    //worksheet.Cells[index + 4, 10].Value = currentRecord.Product_Plan;
                }

                excelPackage.Save();
            }
            return(new FileContentResult(stream.ToArray(), "application/octet-stream")
            {
                FileDownloadName = fileName
            });
        }