示例#1
0
        private List <ImportModel.rawImport> ReadInputFile()
        {
            List <ImportModel.rawImport> recordsIn = new List <ImportModel.rawImport>();
            var fred = TempData["path"].ToString();
            //var filesData = Directory.GetFiles(@fred);
            string path = Server.MapPath("~/App_Data/" + fred);
            //string path = Server.MapPath(fred.ToString());
            var package = new OfficeOpenXml.ExcelPackage(new FileInfo(path));

            OfficeOpenXml.ExcelWorksheet workSheet = package.Workbook.Worksheets[1];


            for (int row = workSheet.Dimension.Start.Row;
                 row <= workSheet.Dimension.End.Row;
                 row++)
            {
                if (ExcelData.HasData(workSheet, row))
                {
                    decimal price             = 0.0m;
                    ImportModel.rawImport obj = new ImportModel.rawImport();
                    obj.Sku          = ExcelData.GetPBSKU(workSheet, row);
                    obj.FormSizeCode = ExcelData.GetPBFSCOde(workSheet, row);
                    obj.Name         = ExcelData.GetName(workSheet, row);
                    obj.FormSize     = ExcelData.GetFSDecription(workSheet, row);
                    price            = ExcelData.GetPrice(workSheet, row);
                    obj.FromDate     = null;
                    // obj.FromDate = ExcelData.GetDate(workSheet, row);
                    obj.Price    = price * 100;
                    obj.Location = "PB";
                    recordsIn.Add(obj);
                }
            }
            return(recordsIn);
        }