Ejemplo n.º 1
0
 /// <summary>
 /// Ote la protection d'une feuille, sans mot de passe
 /// </summary>
 public bool OterProtectionFeuille()
 {
     try
     {
         _MaFeuille.Unprotect(_M);
         return(true);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
         return(false);
     }
 }
Ejemplo n.º 2
0
        public void WriteData(List <FoodAmount> foodnames, string formname)
        {
            int i = 8;

            worksheet = (Worksheet)excelApp.Worksheets["Calculation Sheet"];
            worksheet.Unprotect("cich");

            if ((worksheet.Cells[i, "C"] as Range).Value != null)
            {
                Range foodNames     = worksheet.get_Range(worksheet.Cells[i, "C"], worksheet.Cells[17, "C"]);
                Range rationAmounts = worksheet.get_Range(worksheet.Cells[i, "F"], worksheet.Cells[17, "F"]);
                foodNames     = null;
                rationAmounts = null;
            }

            if (foodnames.Count > 20)
            {
                MessageBox.Show("Sorry! There is a maximum of 20 foods.");
            }
            else
            {
                worksheet.Cells[54, "D"] = formname;
                worksheet.Cells[56, "D"] = DateTime.Now;

                for (int f = 9; f < foodnames.Count - 1; f++)
                {
                    excelApp.Run("AddRow");
                }
                for (int j = 0; j < foodnames.Count; j++)
                {
                    worksheet.Cells[i, "C"] = foodnames[j].Food.Name;
                    worksheet.Cells[i, "F"] = foodnames[j].Amount;
                    i++;
                }
            }

            excelApp.Visible = true;
        }