您好,欢迎访问一九零五行业门户网

php根据excel里面的内容寻找文件的代码

本文主要和大家分享php根据excel里面的内容寻找文件的代码,希望能帮助到大家。
using aspose.cells; using system; using system.collections.generic; using system.io; using system.linq; using system.text.regularexpressions; namespace findfilebyexcel {     class program     {         public static void main(string[] args)         {             //遗漏代码的excel记录文件夹             string excelpath = @c:\users\qingping.li\desktop\股东报告自动化\各种bug\未解决\十大股东遗漏代码.xlsx;             //老的excel存储文件夹             string oldexcelstoragepath = @\\10.10.129.77\巨潮下载测试\2017\第三季度年报测试excel\;             //被挑选出来的excel文件夹             string newexcelstoragepath = @\\10.10.129.77\巨潮下载测试\2017\第三季度年报测试excel\十大股东遗漏\;             //程序集 aspose.cells.dll, v5.3.1.0(运用cell操作类)             cells cells = getexcel(excelpath);             //获得所有文件             string[] excelfiles = directory.getfiles(oldexcelstoragepath);             string signvalue = 002768;             //找到第一个             cell celltable = cells.findstringcontains(signvalue, cells.firstcell);             list<string> list = new list<string>();             if (celltable != null && celltable.value != null)             {                 list.add(celltable.stringvalue);                 cell cellcount = cells.getcell(celltable.row + 1, celltable.column);                 while (cellcount != null && cellcount.stringvalue != null && regex.ismatch(cellcount.stringvalue, @\d))                 {                     cellcount = cells.getcell(cellcount.row + 1, cellcount.column);                     //获得所有的list列表                     if (cellcount != null)                         if (!list.contains(cellcount.stringvalue))                             list.add(cellcount.stringvalue);                 }                 //开始复制所有excel中存在的数据到另外一个文件夹下面                 list<string> copyconpanyexcelfile = new list<string>();                           foreach (string countvaue in list)                 {                                        foreach (string excelfile in excelfiles)                     {                         //如果已经找到了,就不再继续寻找                         if (copyconpanyexcelfile.contains(excelfile))                             continue;                         if (excelfile.indexof(countvaue) > -1)                         {                             if (!directory.exists(newexcelstoragepath))                                 directory.createdirectory(newexcelstoragepath);                             string filename = excelfile.split('\\')[excelfile.split('\\').length - 1];                             try                             {                                 if (!file.exists(newexcelstoragepath + \\ + filename))                                     file.copy(excelfile, newexcelstoragepath + \\ + filename);                                 //将找到的excel文件存储起来;下次就不再寻找                                 copyconpanyexcelfile.add(excelfile);                                 //跳出当前循环                                 break;                             }                             catch                             {                                 continue;                             }                         }                     }                 }             }             console.write(复制完毕!);             console.readkey();         }         public static cells getexcel(string excelpath)         {             workbook workbook = new workbook();             try             {                 workbook.open(excelpath);             }             catch             {                 return null;             }             return workbook.worksheets[0].cells;         }     } }
相关推荐:
php读取excel并展示实现代码
php中通用的excel导出方法实例
node之excel内容的获取
以上就是php根据excel里面的内容寻找文件的代码的详细内容。
其它类似信息

推荐信息