private void MakeCert(JDJLFM jdjlfm, RawTemplate template, string[] A)
        {
            var baseDirectory = Directory.GetCurrentDirectory();
            var imgQRC        = Path.Combine(baseDirectory, @"wwwroot\Temp\" + jdjlfm.ID + ".png");

            if (!File.Exists(imgQRC))
            {
                System.DrawingCore.Image image = SJCLQRCode.GetQRCode(jdjlfm.ID.ToString(), 2); // ID 二维码
                image.Save(imgQRC);
            }
            Document doc = new Document();

            doc.LoadFromFileInReadMode(Path.Combine(baseDirectory, @"wwwroot\DocTemp\" + template.QJMCBM + ".docx"), Spire.Doc.FileFormat.Docx);
            string Y1 = jdjlfm.JDRQ.Year.ToString();
            string M1 = jdjlfm.JDRQ.Month.ToString().PadLeft(2, '0');
            string D1 = jdjlfm.JDRQ.Day.ToString().PadLeft(2, '0');
            string Y2 = "";
            string M2 = "";
            string D2 = "";

            var tmpFieldNames  = new string[] { "QRC", "ZSBH", "DWMC", "QJMC", "XHGG", "CCBH", "ZZC", "JDRQY", "JDRQM", "JDRQD", "YXQZY", "YXQZM", "YXQZD", "A01", "A02", "A03", "A04", "A05", "A06", "A07", "A08", "A09", "A10" };
            var tmpFieldValues = new string[] { imgQRC, jdjlfm.ZSBH, jdjlfm.DWMC, jdjlfm.QJMC, jdjlfm.XHGG, jdjlfm.CCBH, jdjlfm.ZZC, Y1, M1, D1, Y2, M2, D2, A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[8], A[9] };

            //创建合并图片自定义事件
            doc.MailMerge.MergeImageField += new MergeImageFieldEventHandler(MailMerge_MergeImageField);

            //合并模板
            doc.MailMerge.Execute(tmpFieldNames, tmpFieldValues);
            doc.SaveToFile(Path.Combine(baseDirectory, "wwwroot\\Results\\Doc\\" + DateTime.Now.Year + "\\" + template.QJMCBM + "\\" + jdjlfm.ID + ".docx"), Spire.Doc.FileFormat.Docx);
            try
            {
                File.Delete(imgQRC);
            }
            catch { }
        }
        public string[] MakeXls(JDJLFM jdjlfm, RawTemplate template, int[] Signer)
        {
            Random   rnd      = new Random();
            Workbook tempbook = new Workbook();

            tempbook.Version = ExcelVersion.Version2010;
            var baseDirectory = Directory.GetCurrentDirectory();
            var xlsTempPath   = Path.Combine(baseDirectory, @"wwwroot\Templates\" + template.MBMC + ".xls");                         // 模板
            var xlsPath       = Path.Combine(baseDirectory, "wwwroot\\Results\\Xls\\" + DateTime.Now.Year + "\\" + template.QJMCBM); // 原始记录目录
            var docPath       = Path.Combine(baseDirectory, "wwwroot\\Results\\Doc\\" + DateTime.Now.Year + "\\" + template.QJMCBM); // 检定证书目录

            if (!Directory.Exists(xlsPath))
            {
                Directory.CreateDirectory(xlsPath);
            }

            if (!Directory.Exists(docPath))
            {
                Directory.CreateDirectory(docPath);
            }

            tempbook.LoadFromFile(xlsTempPath);
            Worksheet sheet = tempbook.Worksheets[0];

            sheet.Range["B2"].Text = jdjlfm.DWMC;
            sheet.Range["B4"].Text = jdjlfm.QJMC;
            sheet.Range["I4"].Text = jdjlfm.ZSBH;

            string zzc  = jdjlfm.ZZC.ToString().Trim();
            string xhgg = jdjlfm.XHGG.ToString().Trim();
            string ccbh = jdjlfm.CCBH.ToString().Trim();

            if (ccbh == "")
            {
                ccbh = "/";
            }

            string ccbh1, ccbh2 = "";
            string zzc1, zzc2 = "";
            string xhgg1, xhgg2 = "";

            if (zzc.Length > 9)
            {
                zzc1 = zzc.Substring(0, 9);
                zzc2 = zzc.Substring(9, zzc.Length - 9);
            }
            else
            {
                zzc1 = zzc;
            }

            if (xhgg.Length > 12)
            {
                xhgg1 = xhgg.Substring(0, 12);
                xhgg2 = xhgg.Substring(12, xhgg.Length - 12);
            }
            else
            {
                xhgg1 = xhgg;
            }

            if (ccbh.Length > 15)
            {
                ccbh1 = ccbh.Substring(0, 15);
                ccbh2 = ccbh.Substring(15, ccbh.Length - 15);
            }
            else
            {
                ccbh1 = ccbh;
            }

            sheet.Range["B5"].Text = zzc1;
            sheet.Range["F5"].Text = xhgg1;
            sheet.Range["I5"].Text = ccbh1;
            sheet.Range["B6"].Text = zzc2;
            sheet.Range["F6"].Text = xhgg2;
            sheet.Range["I6"].Text = ccbh2;

            //sheet.Range["B14"].DateTimeValue = jdjlfm.JDRQ;
            sheet.Range["B14"].Text = string.Format("{0:D}", Convert.ToDateTime(jdjlfm.JDRQ));
            sheet.Range["G14"].Text = string.Format("{0:D}", Convert.ToDateTime(jdjlfm.JDRQ).AddYears(1).AddDays(-1)); //Convert.ToDateTime(jdjlfm.JDRQ).AddYears(1).AddDays(-1).ToString("D");

            sheet.Range["C13"].Text = jdjlfm.JJWD;

            //原始记录验证码
            sheet.Range["FF1"].Style.Font.Color = Color.White;
            sheet.Range["FF1"].Text             = jdjlfm.ID.ToString();

            // ToDo 数据处理
            sheet = tempbook.Worksheets[1]; // 一
                                            // 数据 - 视准轴竖轴垂直度
            double res = 0.0;

            if (jdjlfm.CJJD == "DS05" || jdjlfm.CJJD == "DS1" || jdjlfm.CJJD == "DS3")
            {
                if (jdjlfm.CJJD == "DS3")
                {
                    res = 2 + Math.Round(rnd.NextDouble() * 3, 0);
                }
                else
                {
                    res = 1 + Math.Round(rnd.NextDouble() * 2, 0);
                }
                sheet.Range["D12"].NumberValue = res; // 交叉误差 3 3 5

                res = 7 + Math.Round(rnd.NextDouble() * 3, 0);
                sheet.Range["D13"].NumberValue = res; // i角误差

                sheet.Range["D15"].Text = "/";        // 自安平的指标
                sheet.Range["D16"].Text = "/";
            }
            else // 自安平
            {
                sheet.Range["D12"].Text = "/"; // 自安平无交叉误差
                res = 7 + Math.Round(rnd.NextDouble() * 3, 0);
                sheet.Range["D13"].NumberValue = res; // i角误差
                                                      // D14,15 从后面读取
                res = 8 + Math.Round(rnd.NextDouble() * 3, 0);
                sheet.Range["D16"].NumberValue = res; // 补偿范围
            }

            sheet = tempbook.Worksheets[2]; // 二

            double apjd = 0;

            double[] APJD = { 0.4, 0.3, 0.45, 0.35, 1, 0.8 };
            switch (jdjlfm.CJJD)
            {
            case "DS05":
                apjd = APJD[0];
                break;

            case "DSZ05":
                apjd = APJD[1];
                break;

            case "DS1":
                apjd = APJD[2];
                break;

            case "DSZ1":
                apjd = APJD[3];
                break;

            case "DS3":
                apjd = APJD[4];
                break;

            case "DSZ3":
                apjd = APJD[5];
                break;
            }
            for (int i = 9; i <= 27; i = i + 2)
            {
                res = 2 + Math.Round(1 - rnd.NextDouble() * 1, 1) * apjd;
                sheet.Range["B" + i].NumberValue = res;
            }
            var ret3 = sheet.Range["I32"].NumberText;

            sheet = tempbook.Worksheets[3]; // 三
            double seed = 10;

            if (jdjlfm.CJJD == "DS3" || jdjlfm.CJJD == "DSZ3")
            {
                seed = 15;
            }
            for (int i = 3; i <= 7; i++)  // 数据 D3 - H6
            {
                for (int j = 2; j < 6; j++)
                {
                    res = 100 + Math.Round(15 - rnd.NextDouble() * 15 * 2, 0);
                    sheet.Range[j, i].NumberValue = res;
                }
            }
            var ret2 = sheet.Range["E17"].NumberText;

            // 测微器行差、回程差 没处理
            sheet = tempbook.Worksheets[4]; // 四
            if (jdjlfm.CJJD == "DS05" || jdjlfm.CJJD == "DS1" || jdjlfm.CJJD == "DS3")
            {
                sheet.Range["D27"].Text    = "/";
                sheet.Range["I27"].Text    = "/";
                sheet.Range["D29"].Text    = "/";
                sheet.Range["I29"].Text    = "/";
                sheet.Range["I31"].Text    = "/";
                sheet.Range["C8:K24"].Text = "/";
            }
            else
            { // 自安平
                for (int i = 8; i < 26; i++)
                {
                    res = 4 + Math.Round(1 - rnd.NextDouble() * 2, 1);
                    sheet.Range["C" + i].NumberValue = res;
                    res = 3 + Math.Round(1 - rnd.NextDouble() * 2, 1);
                    sheet.Range["F" + i].NumberValue = res;
                }
            }
            var ret1 = sheet.Range["I31"].NumberText;

            // 望远镜调焦运行误差,测微器,自安平补偿误差写回P2
            sheet = tempbook.Worksheets[1]; // P2
            if (jdjlfm.CJJD == "DSZ05" || jdjlfm.CJJD == "DSZ1" || jdjlfm.CJJD == "DSZ3")
            {
                //ret1 = x.GetValue(4, "I", 31, 2);
                sheet.Range["D15"].Text = ret1;// .Formula = "=水准仪记录5!I31"; // 来自于 P5         /     ″
            }
            //ret2 = x.GetValue(3, "E", 17, 1);
            sheet.Range["D14"].Text = ret2;//  .Formula = "=水准仪记录4!E17"; // 来自于 P4         mm

            //ret3 = x.GetValue(2, "I", 32, 1);
            sheet.Range["D11"].Text = ret3;// .Formula = "=水准仪记录3!I32"; // 来自于 P3         ″

            //sheet = tempbook.Worksheets[2]; // P3
            //sheet.Range["I32"].NumberValue = ret3;
            //sheet = tempbook.Worksheets[3]; // P4
            //sheet.Range["E17"].NumberValue = ret2;
            //sheet = tempbook.Worksheets[4]; // P5
            //sheet.Range["I31"].NumberValue = ret1;

            /*
             *  // tempbook.PrintDocument.Print();// 免费版只能打印3页
             *  Stream stream = new MemoryStream();
             *  tempbook.SaveToStream(stream);
             *  XlsPrinter.Print(stream);
             */

            tempbook.SaveToFile(Path.Combine(xlsPath, jdjlfm.ID.ToString() + ".xls"));

            string[] RES = new string[10];
            tempbook.CalculateAllValue();

            RES[0] = jdjlfm.JJWD; // A01 温度
            RES[1] = "";          // A02 未用

            sheet  = tempbook.Worksheets[1];
            RES[2] = sheet.Range["D11"].NumberText.ToString(); // A03 视准线的安平误差
            RES[3] = sheet.Range["D12"].NumberText.ToString(); // A04 交叉误差
            RES[4] = sheet.Range["D13"].NumberText.ToString(); // A05 视准线误差(i角误差)
            RES[5] = sheet.Range["D14"].NumberText.ToString(); // A06 望远镜调焦运行误差
            RES[6] = sheet.Range["D9"].NumberText.ToString();  // A07 测微器行差
            RES[7] = sheet.Range["E9"].NumberText.ToString();  // A08 测微器回程差
            RES[8] = sheet.Range["D15"].NumberText.ToString(); // A09 自动安平水准仪补偿误差
            RES[9] = sheet.Range["D16"].NumberText.ToString(); // A10 自动安平水准仪补偿工作范围

            MakeCert(jdjlfm, template, Signer, RES);

            string[] resA17 = new string[RES.Length + 3];
            resA17[0] = jdjlfm.ID.ToString();
            resA17[1] = jdjlfm.ZSBH;
            for (int i = 2; i < resA17.Length - 1; i++)
            {
                resA17[i] = RES[i - 2];
            }
            resA17[resA17.Length - 1] = jdjlfm.CJJD;//精度指标
            return(resA17);
        }
 public override string[] Handle(RawTemplate template, JDJLFM jdjlfm)
 {
     return(MakeXls(jdjlfm, template));
 }
 public abstract string[] Handle(RawTemplate template, JDJLFM jdjlfm);
 public override string[] Handle(RawTemplate template, JDJLFM jdjlfm, int[] Signer)
 {
     return(MakeXls(jdjlfm, template, Signer));
 }
 //public interface IDisposable { };
 //public abstract string Handle(RawTemplate template, JDJLFM jdjlfm, int[] Signer);
 public abstract string[] Handle(RawTemplate template, JDJLFM jdjlfm, int[] Signer);
Beispiel #7
0
        public string[] MakeXls(JDJLFM jdjlfm, RawTemplate template)
        {
            Random   rnd      = new Random();
            Workbook tempbook = new Workbook();

            tempbook.Version = ExcelVersion.Version2010;
            var baseDirectory = Directory.GetCurrentDirectory();
            var xlsTempPath   = Path.Combine(baseDirectory, @"wwwroot\Templates\" + template.MBMC + ".xls");                         // 模板
            var xlsPath       = Path.Combine(baseDirectory, "wwwroot\\Results\\Xls\\" + DateTime.Now.Year + "\\" + template.QJMCBM); // 原始记录目录
            var docPath       = Path.Combine(baseDirectory, "wwwroot\\Results\\Doc\\" + DateTime.Now.Year + "\\" + template.QJMCBM); // 检定证书目录

            if (!Directory.Exists(xlsPath))
            {
                Directory.CreateDirectory(xlsPath);
            }

            if (!Directory.Exists(docPath))
            {
                Directory.CreateDirectory(docPath);
            }

            tempbook.LoadFromFile(xlsTempPath);
            Worksheet sheet = tempbook.Worksheets[0];

            sheet.Range["B2"].Text = jdjlfm.DWMC;
            sheet.Range["B4"].Text = jdjlfm.QJMC;
            sheet.Range["I4"].Text = jdjlfm.ZSBH;

            string zzc  = jdjlfm.ZZC.ToString().Trim();
            string xhgg = jdjlfm.XHGG.ToString().Trim();
            string ccbh = jdjlfm.CCBH.ToString().Trim();

            if (ccbh == "")
            {
                ccbh = "/";
            }

            string ccbh1, ccbh2 = "";
            string zzc1, zzc2 = "";
            string xhgg1, xhgg2 = "";

            if (zzc.Length > 9)
            {
                zzc1 = zzc.Substring(0, 9);
                zzc2 = zzc.Substring(9, zzc.Length - 9);
            }
            else
            {
                zzc1 = zzc;
            }

            if (xhgg.Length > 12)
            {
                xhgg1 = xhgg.Substring(0, 12);
                xhgg2 = xhgg.Substring(12, xhgg.Length - 12);
            }
            else
            {
                xhgg1 = xhgg;
            }

            if (ccbh.Length > 15)
            {
                ccbh1 = ccbh.Substring(0, 15);
                ccbh2 = ccbh.Substring(15, ccbh.Length - 15);
            }
            else
            {
                ccbh1 = ccbh;
            }

            sheet.Range["B5"].Text = zzc1;
            sheet.Range["F5"].Text = xhgg1;
            sheet.Range["I5"].Text = ccbh1;
            sheet.Range["B6"].Text = zzc2;
            sheet.Range["F6"].Text = xhgg2;
            sheet.Range["I6"].Text = ccbh2;

            //sheet.Range["B14"].DateTimeValue = jdjlfm.JDRQ;
            sheet.Range["B14"].Text = string.Format("{0:D}", Convert.ToDateTime(jdjlfm.JDRQ));
            sheet.Range["G14"].Text = string.Format("{0:D}", Convert.ToDateTime(jdjlfm.JDRQ).AddYears(1).AddDays(-1)); //Convert.ToDateTime(jdjlfm.JDRQ).AddYears(1).AddDays(-1).ToString("D");
                                                                                                                       // sheet.Range["G14"].DateTimeValue // 无法设置格式?

            sheet.Range["C13"].Text = jdjlfm.JJWD;

            //原始记录验证码
            sheet.Range["FF1"].Style.Font.Color = Color.White;
            sheet.Range["FF1"].Text             = jdjlfm.ID.ToString();

            // ToDo 数据处理
            sheet = tempbook.Worksheets[1];
            double res = 0;

            for (int i = 1; i <= 10; i++)
            {
                res = 11 + Math.Round(rnd.NextDouble() * 3 / 1000, 3);
                sheet.Range[8, i + 1].NumberValue = res;
            }

            int FH = 0;

            for (int j = 14; j <= 28; j++)
            {
                if (Math.Round(rnd.NextDouble() * 10) > 5)
                {
                    FH = 1;
                }
                else
                {
                    FH = -1;
                }
                for (int i = 1; i <= 5; i++)
                {
                    res = j - 8 + FH * Math.Round(rnd.NextDouble() * 2 / 1000, 3);
                    sheet.Range[j + 1, i + 1].NumberValue = res;
                }
            }

            /*
             *  // tempbook.PrintDocument.Print();// 免费版只能打印3页
             *  Stream stream = new MemoryStream();
             *  tempbook.SaveToStream(stream);
             *  XlsPrinter.Print(stream);
             */

            tempbook.SaveToFile(Path.Combine(xlsPath, jdjlfm.ID.ToString() + ".xls"));

            string[] RES = new string[10];
            tempbook.CalculateAllValue();

            RES[0] = jdjlfm.JJWD; // A01 温度
            RES[1] = "";          // A02 未用

            sheet  = tempbook.Worksheets[1];
            RES[2] = sheet.Range["E10"].NumberText.ToString(); // A03 测量重复性
            RES[3] = sheet.Range["C30"].NumberText.ToString(); // A04 示值误差

            MakeCert(jdjlfm, template, RES);

            string[] resA17 = new string[RES.Length + 2];
            resA17[0] = jdjlfm.ID.ToString();
            resA17[1] = jdjlfm.ZSBH;
            for (int i = 2; i < resA17.Length; i++)
            {
                resA17[i] = RES[i - 2];
            }
            return(resA17);
        }
Beispiel #8
0
        public string MakeXls(RawTemplate template, JDJLFM jdjlfm, int[] Signer)
        {
            Random   rnd      = new Random();
            Workbook tempbook = new Workbook();

            tempbook.Version = ExcelVersion.Version2010;
            var baseDirectory = Directory.GetCurrentDirectory();
            var xlsTempPath   = Path.Combine(baseDirectory, @"wwwroot\Templates\" + template.MBMC + ".xls");                         // 模板
            var xlsPath       = Path.Combine(baseDirectory, "wwwroot\\Results\\Xls\\" + DateTime.Now.Year + "\\" + template.QJMCBM); // 原始记录目录
            var docPath       = Path.Combine(baseDirectory, "wwwroot\\Results\\Doc\\" + DateTime.Now.Year + "\\" + template.QJMCBM); // 检定证书目录

            if (!Directory.Exists(xlsPath))
            {
                Directory.CreateDirectory(xlsPath);
            }

            if (!Directory.Exists(docPath))
            {
                Directory.CreateDirectory(docPath);
            }

            tempbook.LoadFromFile(xlsTempPath);
            Worksheet sheet = tempbook.Worksheets[0];

            sheet.Range["B2"].Text = jdjlfm.DWMC;
            sheet.Range["B4"].Text = jdjlfm.QJMC;
            sheet.Range["I4"].Text = jdjlfm.ZSBH;

            string zzc  = jdjlfm.ZZC.ToString().Trim();
            string xhgg = jdjlfm.XHGG.ToString().Trim();
            string ccbh = jdjlfm.CCBH.ToString().Trim();

            if (ccbh == "")
            {
                ccbh = "/";
            }

            string ccbh1, ccbh2 = "";
            string zzc1, zzc2 = "";
            string xhgg1, xhgg2 = "";

            if (zzc.Length > 9)
            {
                zzc1 = zzc.Substring(0, 9);
                zzc2 = zzc.Substring(9, zzc.Length - 9);
            }
            else
            {
                zzc1 = zzc;
            }

            if (xhgg.Length > 12)
            {
                xhgg1 = xhgg.Substring(0, 12);
                xhgg2 = xhgg.Substring(12, xhgg.Length - 12);
            }
            else
            {
                xhgg1 = xhgg;
            }

            if (ccbh.Length > 15)
            {
                ccbh1 = ccbh.Substring(0, 15);
                ccbh2 = ccbh.Substring(15, ccbh.Length - 15);
            }
            else
            {
                ccbh1 = ccbh;
            }

            sheet.Range["B5"].Text = zzc1;
            sheet.Range["F5"].Text = xhgg1;
            sheet.Range["I5"].Text = ccbh1;
            sheet.Range["B6"].Text = zzc2;
            sheet.Range["F6"].Text = xhgg2;
            sheet.Range["I6"].Text = ccbh2;

            //sheet.Range["B14"].DateTimeValue = jdjlfm.JDRQ;
            sheet.Range["B14"].Text = string.Format("{0:D}", Convert.ToDateTime(jdjlfm.JDRQ));
            sheet.Range["G14"].Text = string.Format("{0:D}", Convert.ToDateTime(jdjlfm.JDRQ).AddYears(1).AddDays(-1)); //Convert.ToDateTime(jdjlfm.JDRQ).AddYears(1).AddDays(-1).ToString("D");
                                                                                                                       // sheet.Range["G14"].DateTimeValue // 无法设置格式?

            sheet.Range["C13"].Text = jdjlfm.JJWD;

            //原始记录验证码
            sheet.Range["FF1"].Style.Font.Color = Color.White;
            sheet.Range["FF1"].Text             = jdjlfm.ID.ToString();

            // ToDo 数据处理
            sheet = tempbook.Worksheets[1];
            double baseline_value = sheet.Range["C10"].NumberValue;

            //double res1 = Math.Round(1 + rnd.NextDouble(), 1);
            //double res2 = Math.Round((1 - rnd.NextDouble() * 2) / 10, 1);
            double res   = 0;
            var    cells = sheet.Range["D10:G10"].CellList;

            foreach (CellRange cell in cells)
            {
                res = Math.Round((baseline_value * 10000 + rnd.Next(-30, 30)) / 10000, 4);
                cell.NumberValue = res;
            }
            baseline_value = sheet.Range["D17"].NumberValue;
            res            = Math.Round((baseline_value * 10000 + rnd.Next(-30, 30) * 10) / 10000, 4);
            sheet.Range["F17"].NumberValue = res;

            /*
             *  // tempbook.PrintDocument.Print();// 免费版只能打印3页
             *  Stream stream = new MemoryStream();
             *  tempbook.SaveToStream(stream);
             *  XlsPrinter.Print(stream);
             */

            tempbook.SaveToFile(Path.Combine(xlsPath, jdjlfm.ID.ToString() + ".xls"));

            string[] RES = new string[5];
            tempbook.CalculateAllValue();
            RES[0] = jdjlfm.JJWD;                              // A01 温度
            RES[2] = sheet.Range["C12"].NumberText.ToString(); // A03 相位误差
            RES[3] = sheet.Range["D17"].NumberText.ToString(); // A04 基线
            RES[4] = sheet.Range["C19"].NumberText.ToString(); // A05 测量误差
            MakeCert(jdjlfm, template, Signer, RES);

            RESA17 resA17 = new RESA17();

            resA17.A01 = RES[0];
            resA17.A03 = RES[2];
            resA17.A04 = RES[3];
            resA17.A05 = RES[4];

            //return resA17;
            return(JsonConvert.SerializeObject(resA17));
        }
        public string[] MakeXls(JDJLFM jdjlfm, RawTemplate template, int[] Signer)
        {
            Workbook tempbook = new Workbook();

            tempbook.Version = ExcelVersion.Version2010;
            var baseDirectory = Directory.GetCurrentDirectory();

            var MBJD = "2";

            // jdjlfm.CJJD 2 5
            if (int.Parse(jdjlfm.CJJD) > 2)
            {
                MBJD = "5";
            }

            var xlsTempPath = Path.Combine(baseDirectory, @"wwwroot\Templates\" + template.MBMC + "-" + MBJD + ".xls");            // 模板
            var xlsPath     = Path.Combine(baseDirectory, "wwwroot\\Results\\Xls\\" + DateTime.Now.Year + "\\" + template.QJMCBM); // 原始记录目录
            var docPath     = Path.Combine(baseDirectory, "wwwroot\\Results\\Doc\\" + DateTime.Now.Year + "\\" + template.QJMCBM); // 检定证书目录

            if (!Directory.Exists(xlsPath))
            {
                Directory.CreateDirectory(xlsPath);
            }

            if (!Directory.Exists(docPath))
            {
                Directory.CreateDirectory(docPath);
            }

            tempbook.LoadFromFile(xlsTempPath);
            sheet = tempbook.Worksheets[0];
            sheet.Range["B2"].Text = jdjlfm.DWMC;
            sheet.Range["B4"].Text = jdjlfm.QJMC;
            sheet.Range["I4"].Text = jdjlfm.ZSBH;

            string zzc  = jdjlfm.ZZC.ToString().Trim();
            string xhgg = jdjlfm.XHGG.ToString().Trim();
            string ccbh = jdjlfm.CCBH.ToString().Trim();

            if (ccbh == "")
            {
                ccbh = "/";
            }

            string ccbh1, ccbh2 = "";
            string zzc1, zzc2 = "";
            string xhgg1, xhgg2 = "";

            if (zzc.Length > 9)
            {
                zzc1 = zzc.Substring(0, 9);
                zzc2 = zzc.Substring(9, zzc.Length - 9);
            }
            else
            {
                zzc1 = zzc;
            }

            if (xhgg.Length > 12)
            {
                xhgg1 = xhgg.Substring(0, 12);
                xhgg2 = xhgg.Substring(12, xhgg.Length - 12);
            }
            else
            {
                xhgg1 = xhgg;
            }

            if (ccbh.Length > 15)
            {
                ccbh1 = ccbh.Substring(0, 15);
                ccbh2 = ccbh.Substring(15, ccbh.Length - 15);
            }
            else
            {
                ccbh1 = ccbh;
            }

            sheet.Range["B5"].Text = zzc1;
            sheet.Range["F5"].Text = xhgg1;
            sheet.Range["I5"].Text = ccbh1;
            sheet.Range["B6"].Text = zzc2;
            sheet.Range["F6"].Text = xhgg2;
            sheet.Range["I6"].Text = ccbh2;


            //sheet.Range["B14"].DateTimeValue = jdjlfm.JDRQ;
            sheet.Range["B14"].Text = string.Format("{0:D}", Convert.ToDateTime(jdjlfm.JDRQ));
            sheet.Range["G14"].Text = string.Format("{0:D}", Convert.ToDateTime(jdjlfm.JDRQ).AddYears(1).AddDays(-1)); //Convert.ToDateTime(jdjlfm.JDRQ).AddYears(1).AddDays(-1).ToString("D");
                                                                                                                       // sheet.Range["G14"].DateTimeValue // 无法设置格式?

            // 日期 -> String
            //XlsWorksheet.TRangeValueType cellType = sheet.GetCellType(14, 2, false); // B14
            //var test = sheet.GetText(14, 2);


            sheet.Range["C13"].Text = jdjlfm.JJWD;
            sheet.Range["G13"].Text = jdjlfm.QT05 + "hPa";

            //原始记录验证码
            sheet.Range["FF1"].Style.Font.Color = Color.White;
            sheet.Range["FF1"].Text             = jdjlfm.ID.ToString();

            // ToDo 数据处理
            Random rnd      = new Random();
            var    cellName = "";

            sheet = tempbook.Worksheets[1];                          // 测角一
            // 数据 - 横轴竖轴垂直度
            double res  = Math.Round(1 + 0.5 - rnd.NextDouble(), 1); // 1±.5
            double res1 = 0;

            cellName = "J10";
            sheet.Range[cellName].NumberValue = res;
            if (double.Parse(jdjlfm.CJJD) < 2)
            {
                res1 = Math.Round((1 - rnd.NextDouble() * 2) / 10, 1);
            }
            else if (double.Parse(jdjlfm.CJJD) == 2)
            {
                res1 = Math.Round((2 - rnd.NextDouble() * 4) / 10, 1);
            }
            else
            {
                res1 = Math.Round((3 - rnd.NextDouble() * 6) / 10, 1);
            }

            if (res1 == 0)
            {
                res1 = 0.1;
            }
            res      = res + res1;
            cellName = "J11";
            sheet.Range[cellName].NumberValue = res;

            // 数据 - 指标差
            cellName = "E13";
            res      = 89;
            sheet.Range[cellName].NumberValue = res;
            cellName = "G13";
            res      = 59;
            sheet.Range[cellName].NumberValue = res;
            cellName = "E14";
            res      = 269;
            sheet.Range[cellName].NumberValue = res;
            cellName = "G14";
            res      = 59;
            sheet.Range[cellName].NumberValue = res;


            res      = Math.Round(58 + 1 - rnd.NextDouble() * 2, 0);
            cellName = "I13";
            sheet.Range[cellName].NumberValue = res;

            res      = Math.Round(57 + 1 - rnd.NextDouble() * 2, 0);
            cellName = "I14";
            sheet.Range[cellName].NumberValue = res;

            cellName = "E15";
            res      = 113;
            sheet.Range[cellName].NumberValue = res;
            cellName = "E16";
            res      = 246;
            sheet.Range[cellName].NumberValue = res;

            res      = Math.Round(5 + 1 - rnd.NextDouble() * 2, 0);
            cellName = "G15";
            sheet.Range[cellName].NumberValue = res;

            res      = 59 - res;
            cellName = "G16";
            sheet.Range[cellName].NumberValue = res;

            res      = Math.Round(45 + 2 - rnd.NextDouble() * 4, 0);
            cellName = "I15";
            sheet.Range[cellName].NumberValue = res;


            res      = 59 - res + Math.Round(1 - rnd.NextDouble() * 2, 0);
            cellName = "I16";
            sheet.Range[cellName].NumberValue = res;

            // 数据 - 照准误差
            sheet.Range["L13"].NumberValue = 0;
            sheet.Range["L14"].NumberValue = 180;
            sheet.Range["L15"].NumberValue = 179;
            sheet.Range["L16"].NumberValue = 0;
            sheet.Range["N13"].NumberValue = 0;
            sheet.Range["N14"].NumberValue = 0;
            sheet.Range["N15"].NumberValue = 59;
            sheet.Range["N16"].NumberValue = 0;

            res = 4 + Math.Round(2 - rnd.NextDouble() * 4, 0);
            sheet.Range["P13"].NumberValue = res;
            res = 4 + Math.Round(2 - rnd.NextDouble() * 4, 0);
            sheet.Range["P14"].NumberValue = res;
            res = 55 + Math.Round(2 - rnd.NextDouble() * 4, 0);
            sheet.Range["P15"].NumberValue = res;
            sheet.Range["P16"].NumberValue = 0;

            // 数据 - 横轴误差
            res = 1 + Math.Round(rnd.NextDouble() * .4, 0);
            sheet.Range["J19"].NumberValue = res;
            res1 = Math.Round((3 - rnd.NextDouble() * 6) / 10, 1);
            if (res1 == 0)
            {
                res1 = 0.1;
            }
            res = res + res1;
            sheet.Range["J20"].NumberValue = res;

            // 数据 - 补偿范围
            sheet.Range["I22"].Text = jdjlfm.QT01;  // 补偿范围来自数据库

            // 数据 - 补偿精度
            sheet.Range["L23"].NumberValue = 89;
            sheet.Range["L24"].NumberValue = 89;
            sheet.Range["N23"].NumberValue = 59;
            sheet.Range["N24"].NumberValue = 59;

            res = 55 + Math.Round(rnd.NextDouble() * 4, 0);
            sheet.Range["P23"].NumberValue = res;
            res = 55 + Math.Round(rnd.NextDouble() * 4, 0);
            sheet.Range["P24"].NumberValue = res;

            if (jdjlfm.QT04 == "2")
            {
                sheet.Range["L25"].NumberValue = 0;
                sheet.Range["L26"].NumberValue = 0;
                sheet.Range["N25"].NumberValue = 0;
                sheet.Range["N26"].NumberValue = 0;
                res = Math.Round(rnd.NextDouble() * 3, 0);
                sheet.Range["P25"].NumberValue = res;
                res = Math.Round(rnd.NextDouble() * 3, 0);
                sheet.Range["P26"].NumberValue = res;
            }
            else
            {
                sheet.Range["L25"].Text = @"\";
                sheet.Range["L26"].Text = @"\";
                sheet.Range["N25"].Text = @"\";
                sheet.Range["N26"].Text = @"\";
                sheet.Range["P25"].Text = @"\";
                sheet.Range["P26"].Text = @"\";
                sheet.Range["L28"].Text = @"\";
            }

            // 数据 - 零位误差
            res = Math.Round(rnd.NextDouble() * 3, 0);
            sheet.Range["H29"].NumberValue = res;
            if (res != 0)
            {
                res++;
            }
            sheet.Range["H30"].NumberValue = res;

            res = Math.Round(rnd.NextDouble() * 3, 0);
            sheet.Range["L29"].NumberValue = res;
            if (res != 0)
            {
                res++;
            }
            sheet.Range["L30"].NumberValue = res;

            sheet = tempbook.Worksheets[2]; // 二
            if (jdjlfm.CJJD == "2")
            {
                sheet.Range["C6"].NumberValue = 0;
                sheet.Range["D6"].NumberValue = 0;

                //多齿分度台标准角值
                double[] J2BZJZ = new double[22];
                int      j      = 0;
                J2BZJZ[j] = 7.8; j++;
                J2BZJZ[j] = 15.7; j++;
                J2BZJZ[j] = 23.5; j++;
                J2BZJZ[j] = 31.3; j++;
                J2BZJZ[j] = 39.1; j++;
                J2BZJZ[j] = 47; j++;
                J2BZJZ[j] = 54.8; j++;
                J2BZJZ[j] = 2.6; j++;
                J2BZJZ[j] = 10.4; j++;
                J2BZJZ[j] = 18.2; j++;
                J2BZJZ[j] = 26; j++;
                J2BZJZ[j] = 33.9; j++;
                J2BZJZ[j] = 41.7; j++;
                J2BZJZ[j] = 49.5; j++;
                J2BZJZ[j] = 57.3; j++;
                J2BZJZ[j] = 05.2; j++;
                J2BZJZ[j] = 13; j++;
                J2BZJZ[j] = 20.8; j++;
                J2BZJZ[j] = 28.6; j++;
                J2BZJZ[j] = 36.5; j++;
                J2BZJZ[j] = 44.3; j++;
                J2BZJZ[j] = 52.2;
                double seed = 2;
                int    zfh  = 1;
                if (double.Parse(jdjlfm.CJJD) <= 1)
                {
                    seed = 0.5;
                }
                for (int i = 7; i <= 28; i++)
                {
                    res = Math.Round(J2BZJZ[i - 7], 0) + Math.Round(seed / 2 - rnd.NextDouble() * seed, 0);
                    sheet.Range["C" + i].NumberValue = res;
                    res1 = Math.Round(seed / 2 - rnd.NextDouble() * seed, 0);
                    if (rnd.NextDouble() > 0.5)
                    {
                        zfh = -1;
                    }
                    else
                    {
                        zfh = 1;
                    }
                    if (res1 == 0)
                    {
                        res1 = 0.1 * zfh;
                    }
                    res = res + res1;
                    sheet.Range["D" + i].NumberValue = res;
                }
            }
            else if (jdjlfm.CJJD == "5")
            {
                for (int i = 6; i <= 17; i++)
                {
                    res = 1 + Math.Round(rnd.NextDouble() * 10, 0);
                    sheet.Range["C" + i].NumberValue = res;
                    res1 = Math.Round(2 - rnd.NextDouble() * 4, 0);
                    if (res1 == 0)
                    {
                        res1 = 0.5;
                    }
                    res = res + res1;
                    sheet.Range["D" + i].NumberValue = res;
                }
            }

            sheet = tempbook.Worksheets[3];             // 三 内符精度
            Calcu_NFJD(jdjlfm.QT02);                    // BCJDA

            sheet = tempbook.Worksheets[4];             // 四 加成常数
            Cal(jdjlfm.JJWD, jdjlfm.QT02, jdjlfm.QT05); // 温度 气压

            /*
             * // tempbook.PrintDocument.Print();// 免费版只能打印3页
             * Stream stream = new MemoryStream();
             * tempbook.SaveToStream(stream);
             * XlsPrinter.Print(stream);
             */

            tempbook.SaveToFile(Path.Combine(xlsPath, jdjlfm.ID.ToString() + ".xls"));

            //System.Diagnostics.Process.Start(Path.Combine(xlsPath, jdjlfm.ID.ToString() + ".xls")); // .net core 不支持

            /*
             * sheet.Range["A2"].Text = "我是A2单元格";
             * sheet.Range["A3"].NumberValue = 100.23;
             * sheet.Range["A4"].DateTimeValue = DateTime.Now;
             * sheet.Range["A5"].BooleanValue = true;
             *
             * Console.WriteLine(sheet.Range["A1"].Value2.ToString());
             * Console.WriteLine(sheet.Range["A1"].Value);
             * Console.WriteLine(sheet.Range["B1"].Text);
             *
             * //对一定范围内的单元格进行字体控制
             * sheet.Range["A1:B10"].Style.Font.FontName = "微软雅黑";
             * sheet.Range["A1:B10"].Style.Font.Size = 20;
             * sheet.Range["A1:B10"].Style.Font.Underline = FontUnderlineType.DoubleAccounting;
             *
             * var columes = sheet.Range["C5:E6"].Columns ;
             * foreach (var column in columes)
             * { }
             */

            string[] RES = new string[17];
            tempbook.CalculateAllValue();
            RES[0] = jdjlfm.JJWD;                              // A01 温度
            RES[1] = jdjlfm.QT05;                              // A02 气压
            sheet  = tempbook.Worksheets[1];
            RES[2] = sheet.Range["H21"].NumberText.ToString(); // A03 横轴误差
            RES[3] = sheet.Range["G12"].NumberText.ToString(); // A04 望远镜视轴对横轴的垂直度
            RES[4] = sheet.Range["E17"].NumberText.ToString(); // A05 指 标 差

            sheet  = tempbook.Worksheets[2];
            RES[5] = sheet.Range["E32"].NumberText.ToString(); // A06 一测回水平方向标准偏差

            sheet   = tempbook.Worksheets[1];
            RES[6]  = sheet.Range["I22"].NumberText.ToString(); // A07 补偿范围
            RES[7]  = sheet.Range["L27"].NumberText.ToString(); // A08 垂直角补偿精度
            RES[8]  = sheet.Range["L28"].NumberText.ToString(); // A09 水平角补偿精度
            RES[9]  = sheet.Range["H29"].NumberText.ToString(); // A10 零位误差X
            RES[10] = sheet.Range["L29"].NumberText.ToString(); // A11 零位误差Y
            RES[11] = sheet.Range["M17"].NumberText.ToString(); // A12 照准误差

            sheet   = tempbook.Worksheets[3];
            RES[12] = sheet.Range["J21"].NumberText.ToString(); // A13 测量重复性

            sheet   = tempbook.Worksheets[4];
            RES[13] = sheet.Range["F52"].NumberText.ToString(); // A14 K
            RES[14] = sheet.Range["F53"].NumberText.ToString(); // A15 R
            RES[15] = sheet.Range["F54"].NumberText.ToString(); // A16 A
            RES[16] = sheet.Range["F55"].NumberText.ToString(); // A17 B

            MakeCert(jdjlfm, template, Signer, RES);

            string[] resA17 = new string[RES.Length + 2];
            resA17[0] = jdjlfm.ID.ToString();
            resA17[1] = jdjlfm.ZSBH;
            for (int i = 2; i < resA17.Length; i++)
            {
                resA17[i] = RES[i - 2];
            }
            return(resA17);
        }
Beispiel #10
0
        public string[] MakeXls(JDJLFM jdjlfm, RawTemplate template, int[] Signer)
        {
            Random   rnd      = new Random();
            Workbook tempbook = new Workbook();

            tempbook.Version = ExcelVersion.Version2010;
            var baseDirectory = Directory.GetCurrentDirectory();
            var MBJD          = jdjlfm.CJJD;                                                                            // 2 6

            var xlsTempPath = Path.Combine(baseDirectory, @"wwwroot\Templates\" + template.MBMC + "-" + MBJD + ".xls"); // 模板

            //var xlsTempPath = Path.Combine(baseDirectory, @"wwwroot\Templates\" + template.MBMC + "-" + jdjlfm.CJJD + ".xls"); // 模板

            var xlsPath = Path.Combine(baseDirectory, "wwwroot\\Results\\Xls\\" + DateTime.Now.Year + "\\" + template.QJMCBM);  // 原始记录目录
            var docPath = Path.Combine(baseDirectory, "wwwroot\\Results\\Doc\\" + DateTime.Now.Year + "\\" + template.QJMCBM);  // 检定证书目录

            if (!Directory.Exists(xlsPath))
            {
                Directory.CreateDirectory(xlsPath);
            }

            if (!Directory.Exists(docPath))
            {
                Directory.CreateDirectory(docPath);
            }

            tempbook.LoadFromFile(xlsTempPath);
            Worksheet sheet = tempbook.Worksheets[0];

            sheet.Range["B2"].Text = jdjlfm.DWMC;
            sheet.Range["B4"].Text = jdjlfm.QJMC;
            sheet.Range["I4"].Text = jdjlfm.ZSBH;

            string zzc  = jdjlfm.ZZC.ToString().Trim();
            string xhgg = jdjlfm.XHGG.ToString().Trim();
            string ccbh = jdjlfm.CCBH.ToString().Trim();

            if (ccbh == "")
            {
                ccbh = "/";
            }

            string ccbh1, ccbh2 = "";
            string zzc1, zzc2 = "";
            string xhgg1, xhgg2 = "";

            if (zzc.Length > 9)
            {
                zzc1 = zzc.Substring(0, 9);
                zzc2 = zzc.Substring(9, zzc.Length - 9);
            }
            else
            {
                zzc1 = zzc;
            }

            if (xhgg.Length > 12)
            {
                xhgg1 = xhgg.Substring(0, 12);
                xhgg2 = xhgg.Substring(12, xhgg.Length - 12);
            }
            else
            {
                xhgg1 = xhgg;
            }

            if (ccbh.Length > 15)
            {
                ccbh1 = ccbh.Substring(0, 15);
                ccbh2 = ccbh.Substring(15, ccbh.Length - 15);
            }
            else
            {
                ccbh1 = ccbh;
            }

            sheet.Range["B5"].Text = zzc1;
            sheet.Range["F5"].Text = xhgg1;
            sheet.Range["I5"].Text = ccbh1;
            sheet.Range["B6"].Text = zzc2;
            sheet.Range["F6"].Text = xhgg2;
            sheet.Range["I6"].Text = ccbh2;

            //sheet.Range["B14"].DateTimeValue = jdjlfm.JDRQ;
            sheet.Range["B14"].Text = string.Format("{0:D}", Convert.ToDateTime(jdjlfm.JDRQ));
            sheet.Range["G14"].Text = string.Format("{0:D}", Convert.ToDateTime(jdjlfm.JDRQ).AddYears(1).AddDays(-1)); //Convert.ToDateTime(jdjlfm.JDRQ).AddYears(1).AddDays(-1).ToString("D");
                                                                                                                       // sheet.Range["G14"].DateTimeValue // 无法设置格式?

            sheet.Range["C13"].Text = jdjlfm.JJWD;

            //原始记录验证码
            sheet.Range["FF1"].Style.Font.Color = Color.White;
            sheet.Range["FF1"].Text             = jdjlfm.ID.ToString();

            // ToDo 数据处理
            sheet = tempbook.Worksheets[1];                          // 一
            // 数据 - 视准轴竖轴垂直度
            double res  = Math.Round(1 + 0.5 - rnd.NextDouble(), 1); // 1±.5
            double res1 = 0;

            sheet.Range["I10"].NumberValue = res;
            res1 = Math.Round((3 - rnd.NextDouble() * 6) / 10, 1);
            if (res1 == 0)
            {
                res1 = 0.1;
            }
            res = res + res1;
            sheet.Range["I11"].NumberValue = res;

            // 数据 - 横轴竖轴垂直度
            res = Math.Round(1 + 0.5 - rnd.NextDouble(), 1); // 1±.5
            sheet.Range["I13"].NumberValue = res;
            res1 = Math.Round((3 - rnd.NextDouble() * 6) / 10, 1);
            if (res1 == 0)
            {
                res1 = 0.1;
            }
            res = res + res1;
            sheet.Range["I14"].NumberValue = res;

            // 数据 - 指标差
            sheet.Range["F16"].NumberValue = 89;
            sheet.Range["H16"].NumberValue = 59;
            sheet.Range["F17"].NumberValue = 269;
            sheet.Range["H17"].NumberValue = 59;

            res = Math.Round(57 + 2 - rnd.NextDouble() * 4, 0);
            sheet.Range["J16"].NumberValue = res;
            res = Math.Round(54 + 2 - rnd.NextDouble() * 4, 0);
            sheet.Range["J17"].NumberValue = res;


            // 数据 - 竖盘指标补偿误差
            sheet.Range["F21"].NumberValue = 90;
            sheet.Range["F22"].NumberValue = 90;
            sheet.Range["F23"].NumberValue = 90;
            sheet.Range["F24"].NumberValue = 90;
            sheet.Range["F25"].NumberValue = 90;
            sheet.Range["H21"].NumberValue = 0;
            sheet.Range["H22"].NumberValue = 0;
            sheet.Range["H23"].NumberValue = 0;
            sheet.Range["H24"].NumberValue = 0;
            sheet.Range["H25"].NumberValue = 0;

            if (jdjlfm.CJJD == "6")  // <12
            {
                res = rnd.NextDouble() >= 0.5 ? 6 : 0;
                sheet.Range["J21"].NumberValue = res;
                res = rnd.NextDouble() >= 0.5 ? 6 : 0;
                sheet.Range["J22"].NumberValue = res;
                res = rnd.NextDouble() >= 0.5 ? 6 : 0;
                sheet.Range["J23"].NumberValue = res;
                res = rnd.NextDouble() >= 0.5 ? 6 : 0;
                sheet.Range["J24"].NumberValue = res;
                res = rnd.NextDouble() >= 0.5 ? 6 : 0;
                sheet.Range["J25"].NumberValue = res;
            }
            else
            {   // <6
                res = Math.Round(4 - rnd.NextDouble() * 4, 0);
                sheet.Range["J21"].NumberValue = res;
                res = Math.Round(4 - rnd.NextDouble() * 4, 0);
                sheet.Range["J22"].NumberValue = res;
                res = Math.Round(4 - rnd.NextDouble() * 4, 0);
                sheet.Range["J23"].NumberValue = res;
                res = Math.Round(4 - rnd.NextDouble() * 4, 0);
                sheet.Range["J24"].NumberValue = res;
                res = Math.Round(4 - rnd.NextDouble() * 4, 0);
                sheet.Range["J25"].NumberValue = res;
            }

            sheet = tempbook.Worksheets[2]; // 二
            if (jdjlfm.CJJD == "2")
            {
                for (int i = 5; i < 10; i++)
                {
                    if (i != 7)
                    {
                        res = Math.Round(1 + rnd.NextDouble() * 10, 0);
                        sheet.Range["I" + i].NumberValue = res;
                        res = Math.Round(1 + rnd.NextDouble() * 10, 0);
                        sheet.Range["O" + i].NumberValue = res;
                        res = Math.Round(3 + rnd.NextDouble() * 10, 0);
                        sheet.Range["U" + i].NumberValue = res;
                        res = Math.Round(3 + rnd.NextDouble() * 10, 0);
                        sheet.Range["AA" + i].NumberValue = res;
                        res = Math.Round(3 + rnd.NextDouble() * 10, 0);
                        sheet.Range["AG" + i].NumberValue = res;
                    }
                }
            }
            else
            {
                for (int i = 5; i < 10; i++)
                {
                    if (i != 7)
                    {
                        res = Math.Round(rnd.NextDouble() * 3 * 6, 0);
                        sheet.Range["I" + i].NumberValue = res;
                        res = Math.Round(rnd.NextDouble() * 3 * 6, 0);
                        sheet.Range["O" + i].NumberValue = res;
                        res = Math.Round(rnd.NextDouble() * 3 * 6, 0);
                        sheet.Range["U" + i].NumberValue = res;
                        res = Math.Round(rnd.NextDouble() * 3 * 6, 0);
                        sheet.Range["AA" + i].NumberValue = res;
                        res = Math.Round(rnd.NextDouble() * 3 * 6, 0);
                        sheet.Range["AG" + i].NumberValue = res;
                    }
                }
            }
            sheet = tempbook.Worksheets[3]; // 三
            if (jdjlfm.CJJD == "2")
            {
                sheet.Range["G7"].NumberValue = Math.Round(rnd.NextDouble() * 4, 0);
                sheet.Range["J7"].NumberValue = Math.Round(rnd.NextDouble() * 6, 0);
                //多齿分度台标准角值
                double[] J2BZJZ = new double[22];
                int      j      = 0;
                J2BZJZ[j] = 7.8; j++;
                J2BZJZ[j] = 15.7; j++;
                J2BZJZ[j] = 23.5; j++;
                J2BZJZ[j] = 31.3; j++;
                J2BZJZ[j] = 39.1; j++;
                J2BZJZ[j] = 47; j++;
                J2BZJZ[j] = 54.8; j++;
                J2BZJZ[j] = 2.6; j++;
                J2BZJZ[j] = 10.4; j++;
                J2BZJZ[j] = 18.2; j++;
                J2BZJZ[j] = 26; j++;
                J2BZJZ[j] = 33.9; j++;
                J2BZJZ[j] = 41.7; j++;
                J2BZJZ[j] = 49.5; j++;
                J2BZJZ[j] = 57.3; j++;
                J2BZJZ[j] = 05.2; j++;
                J2BZJZ[j] = 13; j++;
                J2BZJZ[j] = 20.8; j++;
                J2BZJZ[j] = 28.6; j++;
                J2BZJZ[j] = 36.5; j++;
                J2BZJZ[j] = 44.3; j++;
                J2BZJZ[j] = 52.2;
                for (int i = 8; i <= 29; i++)
                {
                    res = Math.Round(J2BZJZ[i - 8], 0) + Math.Round(1.5 - rnd.NextDouble() * 3, 0);
                    sheet.Range["G" + i].NumberValue = res;
                    res = res + Math.Round(1 - rnd.NextDouble() * 3, 0);
                    sheet.Range["J" + i].NumberValue = res;
                }
            }
            else
            {
                for (int i = 6; i <= 17; i++)
                {
                    res = 1 + Math.Round(rnd.NextDouble() * 10, 0);
                    sheet.Range["C" + i].NumberValue = res;
                    res = res + Math.Round(2 - rnd.NextDouble() * 4, 0);
                    if (res == 0)
                    {
                        res = 2;
                    }
                    sheet.Range["D" + i].NumberValue = res;
                }
            }

            /*
             *  // tempbook.PrintDocument.Print();// 免费版只能打印3页
             *  Stream stream = new MemoryStream();
             *  tempbook.SaveToStream(stream);
             *  XlsPrinter.Print(stream);
             */

            tempbook.SaveToFile(Path.Combine(xlsPath, jdjlfm.ID.ToString() + ".xls"));

            string[] RES = new string[8];
            tempbook.CalculateAllValue();
            RES[0] = jdjlfm.JJWD;                              // A01 温度
            RES[1] = "";                                       // A02 未用
            sheet  = tempbook.Worksheets[1];
            RES[2] = sheet.Range["F12"].NumberText.ToString(); // A03 视准轴与横轴的垂直度
            RES[3] = sheet.Range["G15"].NumberText.ToString(); // A04 横轴与竖轴的垂直度
            RES[4] = sheet.Range["H18"].NumberText.ToString(); // A05 竖盘指标差

            sheet = tempbook.Worksheets[3];
            if (jdjlfm.CJJD == "2")
            {
                RES[5] = sheet.Range["L35"].NumberText.ToString(); // A06 一测回水平方向标准偏差
            }
            else
            {
                RES[5] = sheet.Range["F32"].NumberText.ToString(); // A06 一测回水平方向标准偏差
            }
            sheet  = tempbook.Worksheets[2];
            RES[6] = sheet.Range["D13"].NumberText.ToString(); // A07 望远镜调焦运行误差

            sheet  = tempbook.Worksheets[1];
            RES[7] = sheet.Range["J26"].NumberText.ToString(); // A08 竖盘指标自动补偿误差

            MakeCert(jdjlfm, template, Signer, RES);

            string[] resA17 = new string[RES.Length + 3];
            resA17[0] = jdjlfm.ID.ToString();
            resA17[1] = jdjlfm.ZSBH;
            for (int i = 2; i < resA17.Length - 1; i++)
            {
                resA17[i] = RES[i - 2];
            }
            resA17[resA17.Length - 1] = jdjlfm.CJJD;//精度指标
            return(resA17);
        }