Exemplo n.º 1
0
        private List <Column> GetData()
        {
            List <List <Column> > tempLists = new List <List <Column> >();
            List <Column>         data      = new List <Column>();

            DirectoryInfo d = new DirectoryInfo(Utils.CURRENT_PATH);

            FileInfo[]    Files      = d.GetFiles("*.xlsx");
            List <string> excelNames = new List <string>();

            foreach (FileInfo file in Files)
            {
                if (file.Name.IndexOf("~$") == -1)
                {
                    excelNames.Add(file.Name);
                }
            }
            foreach (string excelName in excelNames)
            {
                string filePath     = Utils.CURRENT_PATH;
                string strRandom    = Utils.RandomString(9);
                string copyFilePath = $@"{filePath}\temp\{strRandom}{excelName}";
                string tempFolder   = $@"{filePath}\temp";
                Utils.CreateFolder(tempFolder);
                filePath = filePath + '\\' + excelName;
                File.Copy(filePath, copyFilePath);
                tempLists.Add(ExcelUtil.GetData(copyFilePath, excelName));
            }

            foreach (List <Column> list in tempLists)
            {
                foreach (Column item in list)
                {
                    data.Add(item);
                }
            }
            return(data);
        }
Exemplo n.º 2
0
        private List <Column> GetData(string originExcelFile)
        {
            List <List <Column> > tempLists = new List <List <Column> >();
            List <Column>         data      = new List <Column>();

            string filePath     = Utils.CURRENT_PATH;
            string strRandom    = Utils.RandomString(9);
            string copyFilePath = $@"{filePath}\temp\{strRandom}{originExcelFile}";
            string tempFolder   = $@"{filePath}\temp";

            Utils.CreateFolder(tempFolder);
            filePath = filePath + '\\' + originExcelFile;
            File.Copy(filePath, copyFilePath);
            tempLists.Add(ExcelUtil.GetData(copyFilePath, originExcelFile));

            foreach (List <Column> list in tempLists)
            {
                foreach (Column item in list)
                {
                    data.Add(item);
                }
            }
            return(data);
        }