基本信息
源码名称:EXCEL数据标记工具
源码大小:11.11M
文件格式:.zip
开发语言:C#
更新时间:2024-10-12
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

 该工具主要是用于标记excel格式的datalog数据,fail的数据背景色标红,利用的是C#操作Excel表格

//QC数据添加条件格式
                        if (QCDataStr != 0)
                        {
                            for (int k = 0; k < ItermQCMaxMin.Count; k )
                            {
                                ExcelAddress excelAddress = new ExcelAddress(QCDataStr, k 1, QCDataEnd, k 1);
                                statement = "";//清楚上次的表达式
                                if (ItermQCMaxMin[k].MaxFlg && ItermQCMaxMin[k].MinFlg)
                                {
                                    // var NotBetween = sheet.ConditionalFormatting.AddNotBetween(excelAddress);
                                    // NotBetween.Formula = ItermQCMaxMin[k].min.ToString();  // 设置下限
                                    // NotBetween.Formula2 = ItermQCMaxMin[k].max.ToString(); // 设置上限
                                    //                                                        //设置样式,例如填充颜色为红色
                                    // NotBetween.Style.Fill.PatternType = ExcelFillStyle.Solid;
                                    // NotBetween.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.Red);

                                    /**************************表达式***********************/
                                    //=AND($KI579<>"",OR($KI579>7,$KI579<3))
                                    //statement = string.Format(CultureInfo.InvariantCulture, "AND({0}>={1},{0}<={2})", new ExcelCellAddress(3, 4).Address, 1, 8);
                                    statement = string.Format(CultureInfo.InvariantCulture, "AND(${0}<>\"\",OR(${0}<{1},${0}>{2}))", new ExcelCellAddress(QCDataStr, k 1).Address, ItermQCMaxMin[k].min, ItermQCMaxMin[k].max);
                                }
                                else if (ItermQCMaxMin[k].MaxFlg)
                                {
                                    //var GreaterThan = sheet.ConditionalFormatting.AddGreaterThan(excelAddress);//添加小于规则
                                    //GreaterThan.Formula = ItermQCMaxMin[k].max.ToString();
                                    ////设置样式,例如填充颜色为红色
                                    //GreaterThan.Style.Fill.PatternType = ExcelFillStyle.Solid;
                                    //GreaterThan.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.Red);

                                    /**************************表达式***********************/
                                    //=AND($KI579<>"",OR($KI579>7,$KI579<3))
                                    //statement = string.Format(CultureInfo.InvariantCulture, "AND({0}>={1},{0}<={2})", new ExcelCellAddress(3, 4).Address, 1, 8);
                                    statement = string.Format(CultureInfo.InvariantCulture, "AND(${0}<>\"\",${0}>{1})", new ExcelCellAddress(QCDataStr, k 1).Address, ItermQCMaxMin[k].max);
                                }
                                else if (ItermQCMaxMin[k].MinFlg)
                                {
                                    // var LessThan = sheet.ConditionalFormatting.AddLessThan(excelAddress);//添加小于规则
                                    // LessThan.Formula = ItermQCMaxMin[k].min.ToString();
                                    // //设置样式,例如填充颜色为红色
                                    // LessThan.Style.Fill.PatternType = ExcelFillStyle.Solid;
                                    // LessThan.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.Red);

                                    /**************************表达式***********************/
                                    //=AND($KI579<>"",OR($KI579>7,$KI579<3))
                                    //statement = string.Format(CultureInfo.InvariantCulture, "AND({0}>={1},{0}<={2})", new ExcelCellAddress(3, 4).Address, 1, 8);
                                    statement = string.Format(CultureInfo.InvariantCulture, "AND(&{0}<>\"\",${0}<{1})", new ExcelCellAddress(QCDataStr, k 1).Address, ItermQCMaxMin[k].min);
                                }

                                if (statement != "")
                                {
                                    //表达式
                                    var Expression = sheet.ConditionalFormatting.AddExpression(excelAddress);
                                    Expression.Formula = statement;
                                    //设置样式,例如填充颜色为红色
                                    Expression.Style.Fill.PatternType = ExcelFillStyle.Solid;
                                    Expression.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.Red);
                                }
                            }
                        }