public void MakeWayBillInExcel(string idWaybill)
 {
     try
     {
         xlApp      = new Excel.Application();
         xlWorkBook = xlApp.Workbooks.Open(ConfigurationManager.AppSettings.Get("PathForOpenBill"));
         xlSheet    = xlWorkBook.Sheets[1];
         SystemOwner  systemOwner  = new OwnerMapper().Get();
         WayBill      wayBill      = new WayBillMapper().Get(idWaybill);
         FileOperator fileOperator = new FileOperator();
         xlSheet.Cells[22, "Y"] = "рейс";
         xlSheet.Cells[5, "B"]  = systemOwner.Bank.Name;
         xlSheet.Cells[5, "X"]  = systemOwner.Bank.BIK;
         xlSheet.Cells[6, "X"]  = systemOwner.Bank.KorBill;
         xlSheet.Cells[9, "B"]  = systemOwner.Name;
         xlSheet.Cells[8, "D"]  = systemOwner.INN;
         xlSheet.Cells[8, "X"]  = systemOwner.Bill;
         xlSheet.Cells[17, "F"] = systemOwner.ToString();
         xlSheet.Cells[30, "H"] = systemOwner.Director.GetFullName();
         xlSheet.Cells[13, "K"] = wayBill.IdWayBill;
         xlSheet.Cells[13, "Q"] = ((DateTime)wayBill.UnloadDate).ToString("dd/MM/yyyy");
         xlSheet.Cells[19, "F"] = $"{wayBill.Client.Name}, ИНН {wayBill.Client.INN}, {wayBill.Client.Address}";
         xlSheet.Cells[22, "D"] = $"Транспортные услуги по маршруту: {wayBill.Trip.Name} " +
                                  $" Водитель: {wayBill.Driver.GetShortName()} Машина: {wayBill.Car.ToString()} По договор-заявке {wayBill.BaseDocument}";
         xlSheet.Cells[22, "AB"] = wayBill.Cost;
         xlSheet.Cells[28, "B"]  = RuDateAndMoneyConverter.CurrencyToTxt(wayBill.Cost, true);
         xlWorkBook.SaveAs(fileOperator.MakeBillPath(wayBill, mainPath));
         xlWorkBook.Close();
         xlApp.Quit();
         while (System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp) > 0)
         {
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show($"Не удалось сделать счет на оплату № {idWaybill}\n" +
                         $"{ex.Message}");
         xlWorkBook.Close(false);
         xlApp.Quit();
         while (System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp) > 0)
         {
         }
     }
 }
 public void MakeBillInExcel(string idRepair)
 {
     try
     {
         xlApp      = new Excel.Application();
         xlWorkBook = xlApp.Workbooks.Open(ConfigurationManager.AppSettings.Get("PathForOpenBill"));
         xlSheet    = xlWorkBook.Sheets[1];
         SystemOwner  systemOwner  = new OwnerMapper().Get();
         CardOfRepair card         = new CardMapper().Get(idRepair.ToString());
         FileOperator fileOperator = new FileOperator();
         xlSheet.Cells[5, "B"]  = systemOwner.Bank.Name;
         xlSheet.Cells[5, "X"]  = systemOwner.Bank.BIK;
         xlSheet.Cells[6, "X"]  = systemOwner.Bank.KorBill;
         xlSheet.Cells[9, "B"]  = systemOwner.Name;
         xlSheet.Cells[8, "D"]  = systemOwner.INN;
         xlSheet.Cells[8, "X"]  = systemOwner.Bill;
         xlSheet.Cells[17, "F"] = systemOwner.ToString();
         xlSheet.Cells[30, "H"] = systemOwner.Director.GetFullName();
         xlSheet.Cells[13, "K"] = card.IdRepair;
         xlSheet.Cells[13, "Q"] = ((DateTime)card.TimeOfFinish).ToString("dd/MM/yyyy");
         xlSheet.Cells[19, "F"] = $"{card.Car.Owner.Name}, ИНН {card.Car.Owner.INN}, {card.Car.Owner.Address}";
         xlSheet.Cells[22, "D"] = $"Ремонт автомобиля: {card.Car.ToString()} по заявке № {idRepair}" +
                                  $" от {((DateTime)card.TimeOfFinish).ToString("dd/MM/yyyy")}";
         xlSheet.Cells[22, "AB"] = card.TotalPrice;
         xlSheet.Cells[28, "B"]  = RuDateAndMoneyConverter.CurrencyToTxt(card.TotalPrice, true);
         xlWorkBook.SaveAs(fileOperator.MakeBillPath(card, mainPath));
         xlWorkBook.Close();
         xlApp.Quit();
         while (System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp) > 0)
         {
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show($"Не удалось сделать счет на оплату № {idRepair}\n" +
                         $"{ex.Message}");
         xlWorkBook.Close(false);
         xlApp.Quit();
         while (System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp) > 0)
         {
         }
     }
 }