Beispiel #1
0
        private void processVoteRate(string txtYiti, string oldCodeText, ResultOk stock)
        {
            if (txtYiti.Length < 20)
            {
                return;
            }
            if (txtYiti.IndexOf("%") < 0 && txtYiti.IndexOf("%") < 0 && txtYiti.IndexOf("票") < 0)
            {
                return;
            }
            string doWhat = ServiceHelp.getDoWhat(txtYiti);

            if (string.IsNullOrEmpty(doWhat))
            {
                return;
            }
            doWhat = "";
            int begin  = 0;
            int tmpLen = 5;

            //Console.WriteLine(txtYiti);

            string splitKeyWord = "";

            //如果只有  一个 ,则不用再细分
            if (ServiceHelp.getStringCount(txtYiti, "弃权") > 1)// || (txtYiti.IndexOf("如下") > 0 && txtYiti.IndexOf("关于") > 0))
            {
                //按"审议通过"  区分
                if (txtYiti.IndexOf("审议通过") < 0)
                {
                    if (txtYiti.IndexOf("议案 ") > 0)
                    {
                        splitKeyWord = "议案 ";
                    }
                    if (txtYiti.IndexOf("如下") > 0 && txtYiti.IndexOf("关于") > 0 && oldCodeText != txtYiti)
                    {
                        splitKeyWord = "关于";
                    }

                    //if (txtYiti.IndexOf("的议案") > 0)
                    //{
                    //    splitKeyWord = "的议案 ";
                    //}
                }
                else
                {
                    splitKeyWord = "审议通过";
                    if (txtYiti.IndexOf("如下") > 0 && txtYiti.IndexOf("关于") > 0 && oldCodeText != txtYiti)
                    {
                        splitKeyWord = "关于";
                    }
                }
            }
            int start = 0;

            while (true)
            {
                if (string.IsNullOrEmpty(splitKeyWord) && start == 0)
                {
                    begin  = 0;
                    tmpLen = txtYiti.Length;
                    start  = txtYiti.Length + 10;
                }
                else
                {
                    if (start >= txtYiti.Length)
                    {
                        break;
                    }
                    begin = txtYiti.IndexOf(splitKeyWord, start);
                    if (begin < 0)
                    {
                        break;
                    }

                    tmpLen = txtYiti.IndexOf(splitKeyWord, begin + 4) - begin;
                    if (tmpLen < 0 && txtYiti.Length > (begin + 20))
                    {
                        //给最后一次机会(处理最后不包含  审议通过的特殊情况)
                        //比如1股权2选举  20150627-000007.SZ-零七股份:2014年年度股东大会决议公告.pdf中第14条
                        if (ServiceHelp.getStringCount(txtYiti.Substring(10, txtYiti.Length - 11), "《") == 1)
                        {
                            tmpLen = txtYiti.IndexOf("《", begin + 20) - begin;
                            if (tmpLen < 0)
                            {
                                tmpLen = txtYiti.Length - begin;
                                start  = begin + 4;
                            }
                            else //if( txtYiti.IndexOf("《", begin + 20) ==txtYiti.LastIndexOf("《", begin + 20))
                            {
                                //再加一个判断,截取后应该含有%,否则不算
                                string abc = txtYiti.Substring(begin, tmpLen);
                                if (abc.IndexOf("%") > 0 || abc.IndexOf("%") > 0)
                                {
                                    splitKeyWord = "《";
                                    start        = begin + 20;
                                }
                                else
                                {
                                    tmpLen = txtYiti.Length - begin;
                                    start  = begin + 4;
                                }
                            }
                        }
                        else
                        {
                            tmpLen = txtYiti.Length - begin;
                            start  = begin + 4;
                        }
                    }
                    else
                    {
                        start = begin + 4;
                    }
                }
                if (tmpLen <= 0)
                {
                    break;
                }
                string txt1 = txtYiti.Substring(begin, tmpLen);

                //有可能不带百分比
                if (txt1.IndexOf("%") < 0 && txt1.IndexOf("%") < 0 && txt1.IndexOf("票") < 0)
                {
                    continue;
                }


                if (splitKeyWord.IndexOf("议案") >= 0)
                {
                    txt1 = txtYiti.Substring(begin - 20, tmpLen - 20);
                }


                doWhat = ServiceHelp.getDoWhat(txt1);
                if (doWhat == "")
                {
                    continue;
                }
                //Console.WriteLine(txt1);
                //Console.WriteLine(doWhat);

                //最后一步,查找 同意 反对 弃权比例
                //类型1:
                //                同意 53,594,429 股,占出席会议所有有表决权股东所持表决权 100%;反对 0 股,占
                //出席会议所有有表决权股东所持表决权 0%;弃权 0 股,占出席会议所有有表决权股东所持
                //表决权 0%。
                if (txt1.IndexOf("同意  反对   弃权") < 0)
                {
                    txt1 = txt1.Replace(" ", "");
                }

                decimal agree    = 0;
                decimal notagree = 0;
                decimal forget   = 0;
                //是同意和反对的
                #region 特殊处理表格
                if (txt1.IndexOf("同意  反对   弃权") >= 0 && txt1.IndexOf("股份总数  同意股数 比例% 反对股数 比例%  弃权股数  比例%") > 0)
                {
                    //出去数字中间的逗号
                    txt1 = txt1.Replace(",", "");
                    //特殊处理表格方式的,表格的格式为

                    int titleIndex = txt1.IndexOf("股份总数  同意股数 比例% 反对股数 比例%  弃权股数  比例%") + "股份总数  同意股数 比例% 反对股数 比例%  弃权股数  比例%".Length;
                    //查找数字开头
                    decimal pp = 0;
                    int     a  = titleIndex;
                    while (!decimal.TryParse(txt1.Substring(a, 1), out pp))
                    {
                        a++;
                    }
                    int b = a;
                    while (decimal.TryParse(txt1.Substring(b, 1), out pp) || txt1.Substring(b, 1) == "." || txt1.Substring(b, 1) == " " || txt1.Substring(b, 1) == "%")
                    {
                        b++;
                    }
                    agree = ServiceHelp.getPersent(txt1, "同意");


                    string data = txt1.Substring(a, b - a);
                    data = data.Replace("%", "");
                    string[] datas = data.Split(' ');
                    if (datas.Length >= 7)
                    {
                        decimal.TryParse(datas[2], out agree);

                        decimal.TryParse(datas[4], out notagree);
                        decimal.TryParse(datas[6], out forget);
                    }
                    if (agree == 100)
                    {
                        //同意为100 则反对,弃权不用再查了
                        notagree = 0;
                        forget   = 0;
                    }
                    else if (agree > 100 || agree < 30)
                    {
                        //如果同意的票数 大于100,认为不是百分比,,或者同意小于30,也认为不是百分比

                        notagree = ServiceHelp.getPersent(txt1, "反对", "num");
                        forget   = ServiceHelp.getPersent(txt1, "弃权", "num");
                    }

                    else
                    {
                        notagree = ServiceHelp.getPersent(txt1, "反对");
                        forget   = ServiceHelp.getPersent(txt1, "弃权");
                        //不等于100,继续找其他的
                    }
                }
                #endregion


                #region  意 反对 弃权  带百分比的
                else if (txt1.IndexOf("票同意") >= 0 && txt1.IndexOf("票反对") >= 0 && txt1.IndexOf("票弃权") >= 0)
                {
                    agree = ServiceHelp.getPersent(txt1, "票同意");
                    if (agree == 100)
                    {
                        //同意为100 则反对,弃权不用再查了
                        notagree = 0;
                        forget   = 0;
                    }
                    else
                    {
                        notagree = ServiceHelp.getPersent(txt1, "票反对");
                        forget   = ServiceHelp.getPersent(txt1, "票弃权");
                        //不等于100,继续找其他的
                    }
                }
                #endregion

                #region  意 反对 弃权  带百分比的
                else if (txt1.IndexOf("同意") >= 0 && (txt1.IndexOf("%", txt1.IndexOf("同意")) > 0 || txt1.IndexOf("%", txt1.IndexOf("同意")) > 0))
                {
                    agree = ServiceHelp.getPersent(txt1, "同意");
                    if (agree == 100)
                    {
                        //同意为100 则反对,弃权不用再查了
                        notagree = 0;
                        forget   = 0;
                    }
                    else if (agree > 100 || agree < 30)
                    {
                        //如果同意的票数 大于100,认为不是百分比,,或者同意小于30,也认为不是百分比

                        notagree = ServiceHelp.getPersent(txt1, "反对", "num");
                        forget   = ServiceHelp.getPersent(txt1, "弃权", "num");
                    }
                    else
                    {
                        notagree = ServiceHelp.getPersent(txt1, "反对");
                        forget   = ServiceHelp.getPersent(txt1, "弃权");
                        //不等于100,继续找其他的
                    }
                }
                #endregion
                #region 赞成   反对 弃权 带%比的
                else if (txt1.IndexOf("赞成") >= 0 && (txt1.IndexOf("%", txt1.IndexOf("赞成")) > 0 || txt1.IndexOf("%", txt1.IndexOf("赞成")) > 0))
                {
                    //查找同意后的第一个 百分比
                    agree = ServiceHelp.getPersent(txt1, "赞成");
                    if (agree == 100)
                    {
                        //同意为100 则反对,弃权不用再查了
                        notagree = 0;
                        forget   = 0;
                    }
                    else if (agree > 100 || agree < 30)
                    {
                        //如果同意的票数 大于100,认为不是百分比,,或者同意小于30,也认为不是百分比

                        notagree = ServiceHelp.getPersent(txt1, "反对", "num");
                        forget   = ServiceHelp.getPersent(txt1, "弃权", "num");
                    }
                    else
                    {
                        //不等于100,继续找其他的
                        //同样的方法查找 反对


                        notagree = ServiceHelp.getPersent(txt1, "反对");
                        forget   = ServiceHelp.getPersent(txt1, "弃权");
                    }
                }
                #endregion
                #region  意 反对 弃权  不带百分比的
                else if (txt1.IndexOf("同意") >= 0 && (txt1.IndexOf("%", txt1.IndexOf("同意")) < 0 && txt1.IndexOf("%", txt1.IndexOf("同意")) < 0))
                {
                    agree = ServiceHelp.getPersent(txt1, "同意");
                    if (agree == 100)
                    {
                        //同意为100 则反对,弃权不用再查了
                        notagree = 0;
                        forget   = 0;
                    }
                    else if (agree > 100 || agree < 30)
                    {
                        //如果同意的票数 大于100,认为不是百分比,,或者同意小于30,也认为不是百分比

                        notagree = ServiceHelp.getPersent(txt1, "反对", "num");
                        forget   = ServiceHelp.getPersent(txt1, "弃权", "num");
                    }
                    else
                    {
                        notagree = ServiceHelp.getPersent(txt1, "反对");
                        forget   = ServiceHelp.getPersent(txt1, "弃权");
                        //不等于100,继续找其他的
                    }
                }
                #endregion

                #region 赞成票
                else if (txt1.IndexOf("赞成票") >= 0 && txt1.IndexOf("反对票") >= 0 && txt1.IndexOf("弃权票") >= 0)
                {
                    //查找同意后的第一个 百分比
                    agree = ServiceHelp.getPersent(txt1, "赞成票");
                    if (agree == 100)
                    {
                        //同意为100 则反对,弃权不用再查了
                        notagree = 0;
                        forget   = 0;
                    }

                    else
                    {
                        //不等于100,继续找其他的
                        //同样的方法查找 反对
                        notagree = ServiceHelp.getPersent(txt1, "反对票");
                        forget   = ServiceHelp.getPersent(txt1, "弃权票");
                    }
                }
                #endregion
                #region  意票 弃权票
                else if (txt1.IndexOf("同意票") >= 0 && txt1.IndexOf("反对票") >= 0 && txt1.IndexOf("弃权票") >= 0)
                {
                    //查找同意后的第一个 百分比
                    agree = ServiceHelp.getPersent(txt1, "同意票");
                    if (agree == 100)
                    {
                        //同意为100 则反对,弃权不用再查了
                        notagree = 0;
                        forget   = 0;
                    }

                    else
                    {
                        //不等于100,继续找其他的
                        //同样的方法查找 反对
                        notagree = ServiceHelp.getPersent(txt1, "反对票");
                        forget   = ServiceHelp.getPersent(txt1, "弃权票");
                    }
                }
                #endregion
                else
                {
                    // Console.WriteLine("不包含同意");
                }
                ResultOk newStock = new ResultOk(stock.fileName, stock.code, stock.name, stock.date);
                newStock.doWhat = doWhat;

                if ((notagree + forget + agree) < 0)
                {
                    agree = 100;
                }
                if (agree == 0 && notagree == 0 && forget == 0)
                {
                    agree = 100;
                }
                else if (notagree == 0 && forget == 0)
                {
                    agree = 100;
                }
                else if ((notagree + forget + agree) > 100 || (notagree + forget + agree) < 90)
                {
                    if ((notagree + forget + agree) > 100 && (notagree + agree) == 100)
                    {
                        forget = 0;
                    }
                    else
                    {
                        decimal agree1    = agree;
                        decimal notagree2 = notagree;

                        agree    = (agree / (notagree2 + forget + agree1)) * 100;
                        notagree = (notagree / (notagree2 + forget + agree1)) * 100;
                        forget   = (forget / (notagree2 + forget + agree1)) * 100;

                        agree    = Math.Round(agree, 4);
                        notagree = Math.Round(notagree, 4);
                        forget   = Math.Round(forget, 4);
                    }
                }

                newStock.agree    = agree + "";
                newStock.notagree = notagree + "";
                newStock.forget   = forget + "";

                listResultOk.Add(newStock);
                continue;
            }
        }
Beispiel #2
0
        private void DoAnaylese()
        {
            string rootDir = strTxtFolderName;

            listResultOk.Clear();
            listResultError.Clear();

            DirectoryInfo root = new DirectoryInfo(rootDir);

            FileInfo[] files = root.GetFiles("*.txt");
            if (files.Length == 0)
            {
                MessageBox.Show("文件夹下不包含txt文件.");
                return;
            }
            this.BeginInvoke(new MethodInvoker(delegate()
            {
                btnRead.Enabled    = false;
                btnConvert.Enabled = false;
                btnAnaylse.Enabled = false;
            }));
            string code = "";
            string name = "";
            string date = "";

            int begin  = 0;
            int tmpLen = 5;

            SetLableText("转换完成,开始分析txt文件", lblInfo);
            SetPbValue(0);
            for (int i = 0; i < files.Length; i++)
            {
                SetLableText(string.Format("分析文件.已处理{0},共:{1},完成比例:{2}%", i + 1, files.Length, decimal.Round((Convert.ToDecimal(i + 1) / Convert.ToDecimal(files.Length) * 100), 2).ToString()), lblInfo);
                bool hasError       = false;
                int  beginListCount = listResultOk.Count;

                SetPbValue((int)decimal.Round((Convert.ToDecimal(i + 1) / Convert.ToDecimal(files.Length) * 100), 2));
                code = "";
                name = "";
                date = "";
                FileInfo txtFile = files[i];
                try
                {
                    #region
                    string       oldCodeText = "";
                    StreamReader CodeReader  = new StreamReader(txtFile.FullName, Encoding.Default);
                    oldCodeText = CodeReader.ReadToEnd();
                    CodeReader.Close();
                    //根据标题做第一次筛选.截取前200位,任务里面还有标题
                    string titleContext = oldCodeText.Replace(" ", "");
                    if (titleContext.Length > 200)
                    {
                        titleContext = titleContext.Substring(0, 200);
                    }
                    if (titleContext.IndexOf("决议公告") < 0 && titleContext.IndexOf("决议的公告") < 0)
                    {
                        if (titleContext.IndexOf("大会通知的公告") > 0)
                        {
                            throw new Exception("大会通知的公告,不用处理.");
                        }
                        if (titleContext.IndexOf("股东大会的公告") > 0)
                        {
                            throw new Exception("股东大会的公告,不用处理.");
                        }
                        if (titleContext.IndexOf("提示性公告") > 0)
                        {
                            throw new Exception("提示性公告,不用处理.");
                        }
                        if (titleContext.IndexOf("补充通知的公告") > 0)
                        {
                            throw new Exception("补充通知的公告,不用处理.");
                        }
                        if (titleContext.IndexOf("通知的公告") > 0)
                        {
                            throw new Exception("通知的公告,不用处理.");
                        }

                        throw new Exception("不包含[决议公告]和[决议的公告],不用处理.");
                    }

                    if (oldCodeText.IndexOf("附件 1:") > 0)
                    {
                        //如果有附件,,则附件不考虑,直接截取掉
                        oldCodeText = oldCodeText.Substring(0, oldCodeText.IndexOf("附件 1:"));
                    }
                    if (oldCodeText.IndexOf("附件一:") > 0)
                    {
                        //如果有附件,,则附件不考虑,直接截取掉
                        oldCodeText = oldCodeText.Substring(0, oldCodeText.IndexOf("附件一:"));
                    }
                    if (oldCodeText.IndexOf("附件 一 :") > 0)
                    {
                        //如果有附件,,则附件不考虑,直接截取掉
                        oldCodeText = oldCodeText.Substring(0, oldCodeText.IndexOf("附件 一 :"));
                    }

                    //先getdowhat找不到算了
                    if (string.IsNullOrEmpty(ServiceHelp.getDoWhat(oldCodeText)))
                    {
                        throw new Exception("没找到关键字,不用处理.");
                    }


                    //查找code
                    code = ServiceHelp.getCode(oldCodeText);
                    //查找name
                    name = ServiceHelp.getName(oldCodeText);
                    //查找时间
                    date = ServiceHelp.getDate(oldCodeText);
                    if (date.Length > 10 && date.IndexOf("年") > 0)
                    {
                        //对日期再一次处理  //2010年7/18
                        date = date.Substring(0, 4) + "/" + date.Substring(date.LastIndexOf("年") + 1);
                    }

                    ResultOk stock = new ResultOk(txtFile.FullName, code, name, date);
                    //查找关键字
                    //规律1:都在提审议案和表决情况     提案审议
                    //选举	1提名
                    //    2增补
                    //    3选举
                    //担保	4担保
                    //并购	5股权            竞购  30%股权              -表决结果
                    //    6资产

                    //Console.WriteLine(txtFile.FullName);
                    //Console.WriteLine(code + "__" + name + "__" + date);
                    string txtYiti = "";
                    if (oldCodeText.IndexOf("议案的审议和表决情况") > 0 || oldCodeText.IndexOf("议案的审议和表决情况") > 0 || oldCodeText.IndexOf("提案审议") > 0 || oldCodeText.IndexOf("提审议案") > 0 || oldCodeText.IndexOf("议案审议") > 0)
                    {
                        // 提案审议情况
                        begin = oldCodeText.IndexOf("提案审议");
                        if (begin < 0)
                        {
                            begin = oldCodeText.IndexOf("提审议案");
                        }
                        if (begin < 0)
                        {
                            begin = oldCodeText.IndexOf("议案审议");
                        }
                        if (begin < 0)
                        {
                            begin = oldCodeText.IndexOf("议案的审议和表决情况");
                        }
                        if (oldCodeText.IndexOf("律师出具", begin) > 0)
                        {
                            tmpLen = oldCodeText.IndexOf("律师出具", begin) - begin;
                        }
                        else if (oldCodeText.IndexOf("律师见证情况", begin) > 0)
                        {
                            tmpLen = oldCodeText.IndexOf("律师见证情况", begin) - begin;
                        }

                        if (tmpLen > 0)
                        {
                            if (tmpLen > oldCodeText.Length)
                            {
                                tmpLen = oldCodeText.Length;
                            }
                            try
                            {
                                txtYiti = oldCodeText.Substring(begin + 5, tmpLen);
                            }
                            catch
                            {
                                txtYiti = oldCodeText;// 针对不包含 具体项的
                            }
                        }
                    }
                    else
                    {
                        txtYiti = oldCodeText;// 针对不包含 具体项的
                    }
                    if (txtYiti.Length < 200)
                    {
                        txtYiti = oldCodeText;// 针对不包含 具体项的
                    }

                    //去空格,,,针对 一些关键字加空格的情况
                    if (txtYiti.IndexOf("审议 通过") >= 0)
                    {
                        txtYiti = txtYiti.Replace(" ", "");
                    }
                    string splitKeyWord = "";
                    //按"审议通过"  区分
                    if (txtYiti.IndexOf("审议通过") < 0)
                    {
                        //
                        //Console.WriteLine("不包含   审议通过");
                        if (txtYiti.IndexOf("议案 ") > 0)
                        {
                            splitKeyWord = "议案 ";
                        }
                        //Console.WriteLine("不包含   议案 ");
                        //if (txtYiti.IndexOf("的议案") > 0)
                        //{
                        //    splitKeyWord = "的议案 ";
                        //}
                    }
                    else
                    {
                        splitKeyWord = "审议通过";
                    }

                    int start = 0;
                    while (true)
                    {
                        if (string.IsNullOrEmpty(splitKeyWord) && start == 0)
                        {
                            begin  = 0;
                            tmpLen = txtYiti.Length;
                            start  = txtYiti.Length + 10;
                        }
                        else
                        {
                            if (start >= txtYiti.Length)
                            {
                                break;
                            }
                            begin = txtYiti.IndexOf(splitKeyWord, start);
                            if (begin < 0)
                            {
                                break;
                            }

                            tmpLen = txtYiti.IndexOf(splitKeyWord, begin + 4) - begin;

                            string txt2 = txtYiti.Substring(begin, tmpLen > 0 ? tmpLen : txtYiti.Length - begin);
                            if (tmpLen < 0)
                            {
                                //给最后一次机会(处理最后不包含  审议通过的特殊情况)
                                //比如1股权2选举  20150627-000007.SZ-零七股份:2014年年度股东大会决议公告.pdf中第14条
                                if (ServiceHelp.getStringCount(txt2, "关于") > 1)
                                {
                                    tmpLen = txtYiti.IndexOf("《", begin + 20) - begin;
                                    if (tmpLen < 0)
                                    {
                                        tmpLen = txtYiti.Length - begin;
                                        start  = begin + 4;
                                    }
                                    else //if( txtYiti.IndexOf("《", begin + 20) ==txtYiti.LastIndexOf("《", begin + 20))
                                    {
                                        //再加一个判断,截取后应该含有%,否则不算
                                        string abc = txtYiti.Substring(begin, tmpLen);
                                        if (abc.IndexOf("%") > 0 || abc.IndexOf("%") > 0)
                                        {
                                            splitKeyWord = "《";
                                            start        = begin + 20;
                                        }
                                        else
                                        {
                                            tmpLen = txtYiti.Length - begin;
                                            start  = begin + 4;
                                        }
                                    }
                                }
                                else
                                {
                                    tmpLen = txtYiti.Length - begin;
                                    start  = begin + 4;
                                }
                            }
                            else
                            {
                                start = begin + 4;
                            }
                        }
                        string txt1 = txtYiti.Substring(begin, tmpLen);

                        if (splitKeyWord.IndexOf("议案") >= 0)
                        {
                            txt1 = txtYiti.Substring(begin - 20, tmpLen);
                        }
                        processVoteRate(txt1, oldCodeText, stock);
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    if (ex.Message.IndexOf("不用处理") < 0)
                    {
                        Console.WriteLine(txtFile.FullName);
                        Console.WriteLine(ex.Message);
                        Console.WriteLine(ex.StackTrace);
                    }
                    hasError = true;
                    //TODO:这个地方加了个容错,就是如果一个文件有正确结果后再出错则忽略
                    if (beginListCount == listResultOk.Count)
                    {
                        //没找到
                        listResultError.Add(new ResultOk(txtFile.FullName, code, name, date, ex.Message));
                    }
                    else
                    {
                        Console.WriteLine(ex.ToString());
                    }
                    //listResultError.Add(new ResultOk(txtFile.FullName, code, name, date,"分析中出错"));
                }
                if (beginListCount == listResultOk.Count && !hasError)
                {
                    //没找到
                    listResultError.Add(new ResultOk(txtFile.FullName, code, name, date, "没找到关键字,不用处理"));
                }
            }

            //将结果输出到excel中
            string resultFileName = ServiceHelp.printResult(rootDir, listResultOk, listResultError);
            SetLableText(resultFileName, txtResult);

            this.BeginInvoke(new MethodInvoker(delegate()
            {
                btnRead.Enabled    = true;
                btnConvert.Enabled = true;
                btnAnaylse.Enabled = true;
            }));
        }
Beispiel #3
0
        public static string printResult(string folder, List <ResultOk> listResultOk, List <ResultOk> listResultError)
        {
            string   resultXlsFileName = "result" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
            string   strFilePath       = System.IO.Path.Combine(folder, resultXlsFileName);
            FileInfo file = new FileInfo(strFilePath);
            //应该是只有一条记录
            string tmp = "";

            //将连着的一样的文件,单独列入一个sheet内
            List <ResultOk> listResultTheSame = new List <ResultOk>();

            for (int i = 1; i < listResultOk.Count; i++)
            {
                //如果连着两条记录完全一样,则加到 listResultTheSame 中
                ResultOk before = listResultOk[i - 1];
                ResultOk now    = listResultOk[i];

                //比较是否一样
                if (before.fileName == now.fileName)
                {
                    if (before.code == now.code)
                    {
                        if (before.date == now.date)
                        {
                            if (before.remark == now.remark)
                            {
                                if (before.agree == now.agree)
                                {
                                    if (before.notagree == now.notagree)
                                    {
                                        if (before.forget == now.forget)
                                        {
                                            //认为是一样的,则加入到 另一个列表中
                                            listResultTheSame.Add(now);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            using (ExcelPackage package = new ExcelPackage(file))
            {
                bool   isPdfExit  = false;
                string parentPath = "";
                if (listResultOk.Count > 0 && !string.IsNullOrEmpty(listResultOk[0].fileName))
                {
                    //查看上层目录下的pdf是否存在,存在则文件 用pdf的全路径
                    string fileTmp = listResultOk[0].fileName;
                    parentPath = fileTmp.Substring(0, fileTmp.LastIndexOf("\\"));
                    if (parentPath.LastIndexOf("\\") > 0)
                    {
                        parentPath = parentPath.Substring(0, parentPath.LastIndexOf("\\")) + "\\";
                    }

                    string pdf = parentPath + fileTmp.Substring(fileTmp.LastIndexOf("\\"), fileTmp.LastIndexOf(".") - fileTmp.LastIndexOf("\\")) + ".pdf";

                    if (File.Exists(pdf))
                    {
                        isPdfExit = true;
                    }
                }

                //第一个sheet
                ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("result");
                //特殊的几个位置
                worksheet.Cells["A1"].Value = "name";
                worksheet.Cells["B1"].Value = "date";
                worksheet.Column(2).Width   = 20;
                worksheet.Cells["C1"].Value = "关键字";
                worksheet.Cells["D1"].Value = "赞成%";
                worksheet.Cells["E1"].Value = "反对%";
                worksheet.Cells["F1"].Value = "弃权%";
                worksheet.Cells["G1"].Value = "备注";

                // worksheet.Cells["H1"].Value = "证券名";
                worksheet.Cells["H1"].Value = "txt文件名";
                worksheet.Cells["I1"].Value = "pdf文件名";

                worksheet.Column(8).Width = 60;
                worksheet.Column(9).Width = 60;
                //将listResult打印出来
                for (int i = 0; i < listResultOk.Count; i++)
                {
                    ResultOk stock = listResultOk[i];
                    //Console.WriteLine(stock.code + "__" + stock.name + "__" + stock.date + "__" + stock.doWhat + "___" + stock.agree + "__" + stock.notagree + "__" + stock.forget + "__" + stock.remark);
                    worksheet.Cells[i + 2, 1].Value = stock.code;
                    worksheet.Cells[i + 2, 2].Value = stock.date;
                    worksheet.Cells[i + 2, 3].Value = stock.doCode;
                    worksheet.Cells[i + 2, 4].Value = stock.agree;
                    worksheet.Cells[i + 2, 5].Value = stock.notagree;
                    worksheet.Cells[i + 2, 6].Value = stock.forget;
                    worksheet.Cells[i + 2, 7].Value = stock.remark;
                    //worksheet.Cells[i + 2, 8].Value = stock.name;

                    string fileName1 = stock.fileName.Substring(stock.fileName.LastIndexOf("\\") + 1, stock.fileName.LastIndexOf(".") - stock.fileName.LastIndexOf("\\") - 1);
                    worksheet.Cells[i + 2, 8].Formula = "HYPERLINK(\"" + stock.fileName + "\",\"" + fileName1 + ".txt\")";
                    //worksheet.Cells[i + 2, 9].Value = "=HYPERLINK(\"" + stock.fileName + "\")";

                    try
                    {
                        if (isPdfExit)
                        {
                            string pdf = parentPath + fileName1 + ".pdf";
                            worksheet.Cells[i + 2, 9].Formula = "HYPERLINK(\"" + parentPath + fileName1 + ".pdf\",\"" + fileName1 + ".pdf\")";
                        }
                    }
                    catch (Exception)
                    {
                    }
                }


                //第2个sheet
                ExcelWorksheet worksheet2 = package.Workbook.Worksheets.Add("Error");
                //特殊的几个位置
                worksheet2.Cells["A1"].Value = "name";
                worksheet2.Cells["B1"].Value = "date";
                worksheet2.Column(2).Width   = 20;

                worksheet2.Cells["C1"].Value = "备注";
                worksheet2.Column(3).Width   = 30;
                worksheet2.Cells["D1"].Value = "文件名";
                worksheet2.Column(2).Width   = 40;
                // worksheet.Cells["I1"].Value = "文件名";
                //CEMS运维联系人:                                                                   联系电话/手机:
                //将listResult打印出来
                for (int i = 0; i < listResultError.Count; i++)
                {
                    ResultOk stock = listResultError[i];

                    if (true)// (stock.remark.IndexOf("不用处理") < 0)
                    {
                        if (!Directory.Exists(folder + "\\a\\"))
                        {
                            Directory.CreateDirectory(folder + "\\a\\");
                        }
                        File.Copy(stock.fileName, folder + "\\a\\" + stock.fileName.Replace(folder, ""), true);
                    }


                    string fileName1 = stock.fileName.Substring(stock.fileName.LastIndexOf("\\") + 1, stock.fileName.LastIndexOf(".") - stock.fileName.LastIndexOf("\\") - 1);

                    // Console.WriteLine(stock.code + "__" + stock.name + "__" + stock.date + "__" + stock.doWhat + "___" + stock.agree + "__" + stock.notagree + "__" + stock.forget + "__" + stock.remark);

                    worksheet2.Cells[i + 2, 1].Value   = stock.code;
                    worksheet2.Cells[i + 2, 2].Value   = stock.date;
                    worksheet2.Cells[i + 2, 4].Formula = "HYPERLINK(\"" + stock.fileName + "\",\"" + fileName1 + ".txt\")";
                    // worksheet2.Cells[i + 2, 4].Value = "=HYPERLINK(\"" + stock.fileName + "\")";
                    worksheet2.Cells[i + 2, 3].Value = stock.remark;
                    //worksheet.Cells[i + 2, 1].Value = stock.code;
                    //将错误文件移到到一个独立的文件夹中
                    try
                    {
                        if (isPdfExit)
                        {
                            string pdf = parentPath + fileName1 + ".pdf";
                            worksheet.Cells[i + 2, 3].Formula = "HYPERLINK(\"" + parentPath + fileName1 + "\",\"" + fileName1 + ".pdf\")";
                        }
                    }
                    catch (Exception)
                    {
                    }
                }



                //第一个sheet
                ExcelWorksheet worksheet3 = package.Workbook.Worksheets.Add("resultSame");
                //特殊的几个位置
                worksheet3.Cells["A1"].Value = "name";
                worksheet3.Cells["B1"].Value = "date";
                worksheet3.Column(2).Width   = 20;
                worksheet3.Cells["C1"].Value = "关键字";
                worksheet3.Cells["D1"].Value = "赞成%";
                worksheet3.Cells["E1"].Value = "反对%";
                worksheet3.Cells["F1"].Value = "弃权%";
                worksheet3.Cells["G1"].Value = "备注";

                // worksheet3.Cells["H1"].Value = "证券名";
                worksheet3.Cells["H1"].Value = "txt文件名";
                worksheet3.Cells["I1"].Value = "pdf文件名";

                worksheet3.Column(8).Width = 60;
                worksheet3.Column(9).Width = 60;
                //将listResult打印出来
                for (int i = 0; i < listResultTheSame.Count; i++)
                {
                    ResultOk stock = listResultTheSame[i];
                    //Console.WriteLine(stock.code + "__" + stock.name + "__" + stock.date + "__" + stock.doWhat + "___" + stock.agree + "__" + stock.notagree + "__" + stock.forget + "__" + stock.remark);
                    worksheet3.Cells[i + 2, 1].Value = stock.code;
                    worksheet3.Cells[i + 2, 2].Value = stock.date;
                    worksheet3.Cells[i + 2, 3].Value = stock.doCode;
                    worksheet3.Cells[i + 2, 4].Value = stock.agree;
                    worksheet3.Cells[i + 2, 5].Value = stock.notagree;
                    worksheet3.Cells[i + 2, 6].Value = stock.forget;
                    worksheet3.Cells[i + 2, 7].Value = stock.remark;
                    //worksheet3.Cells[i + 2, 8].Value = stock.name;

                    string fileName1 = stock.fileName.Substring(stock.fileName.LastIndexOf("\\") + 1, stock.fileName.LastIndexOf(".") - stock.fileName.LastIndexOf("\\") - 1);
                    worksheet3.Cells[i + 2, 8].Formula = "HYPERLINK(\"" + stock.fileName + "\",\"" + fileName1 + ".txt\")";
                    //worksheet3.Cells[i + 2, 9].Value = "=HYPERLINK(\"" + stock.fileName + "\")";

                    try
                    {
                        if (isPdfExit)
                        {
                            string pdf = parentPath + fileName1 + ".pdf";
                            worksheet3.Cells[i + 2, 9].Formula = "HYPERLINK(\"" + parentPath + fileName1 + ".pdf\",\"" + fileName1 + ".pdf\")";
                        }
                    }
                    catch (Exception)
                    {
                    }
                }



                package.Save();
            }
            return(strFilePath);
            // SetLableText(strFilePath, txtResult);
            //this.txtResult.Text = strFilePath;
        }