private void SaveJ_Click(object sender, RoutedEventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog { Filter = "Excel file (*.xlsx)|*.xlsx", InitialDirectory = @"C:\Users\lenovo\Desktop\movies" }; StatJour statJour = new StatJour(Variable, Wilaya, AnneeJour, Mois); _Application excel = new _Excel.Application(); if (saveFileDialog.ShowDialog() == true) { string filename = System.IO.Path.GetFileName(saveFileDialog.FileName); String path = System.IO.Path.GetDirectoryName(saveFileDialog.FileName); Workbook wb = excel.Workbooks.Add(XlWBATemplate.xlWBATWorksheet); Worksheet ws = wb.Worksheets[1]; ws.Cells[1, 1] = "Les statistiques journaliere."; ws.Cells[2, 1] = "La Wilaya :"; ws.Cells[2, 2] = ((WilayaAlgerie)(statJour.Wilaya - 1)).ToString(); ws.Cells[3, 1] = "Le variable meteorologique :"; ws.Cells[3, 2] = nomVariable; ws.Cells[4, 1] = "L'année :"; ws.Cells[4, 2] = statJour.Annee; ws.Cells[5, 1] = "Le mois :"; ws.Cells[5, 2] = ((Month)(statJour.Mois - 1)).ToString(); ws.Cells[7, 1] = "La valeur maximale :"; ws.Cells[7, 2] = statJour.Max.Item2; ws.Cells[7, 3] = "Atteint le " + statJour.Max.Item1 + " " + ((Month)(statJour.Mois - 1)).ToString(); ws.Cells[8, 1] = "La valeur minimale :"; ws.Cells[8, 2] = statJour.Min.Item2; ws.Cells[8, 3] = "Atteint le " + statJour.Min.Item1 + " " + ((Month)(statJour.Mois - 1)).ToString(); ws.Cells[10, 1] = "Le jour"; ws.Cells[10, 2] = "La valeur "; int i = 11; foreach (Tuple <int, float> stat in statJour.Tableau) { ws.Cells[i, 1] = stat.Item1; ws.Cells[i, 2] = stat.Item2; i++; } MessageBoxAlert.Show("Fin du sauvgarde", "Les Resultats sont bien enregistrés \n Le chemin du fichier : " + path + "\\" + filename); excel.DisplayAlerts = false; wb.SaveAs(path + "\\" + filename); wb.Close(); excel.Quit(); } }
public void StatJour() { StatJour statJour = new StatJour(Variable, Wilaya, AnneeJour, Mois); if (statJour.Tableau == null || statJour.Tableau.Count < 1) { MessageBoxAlert.Show("Manque des données", "Il y'a un manque de donnée dans ce mois!"); } else { if (Variable != 1) { Diagramme diagramme = new Diagramme(statJour.Tableau) { Height = 300, Width = 650 }; Courbe courbe = new Courbe(statJour.Tableau) { Height = 300, Width = 650 }; TabViewJD.Content = diagramme; TabViewJC.Content = courbe; Record2J.Text = "Max " + statJour.Max.Item2 + " " + UniteMesure; Record1J.Text = "Min " + statJour.Min.Item2 + " " + UniteMesure; } else { StatJour statJour1 = new StatJour(2, Wilaya, AnneeJour, Mois); Doublecourbe courbe = new Doublecourbe(statJour.Tableau, statJour1.Tableau) { Height = 300, Width = 650 }; TabViewJC.Content = courbe; Record2J.Text = "Max " + statJour1.Max.Item2 + " " + UniteMesure + " " + AnneeJour + " " + (Month)(Mois - 1) + " " + statJour1.Max.Item1; Record1J.Text = "Min " + statJour.Min.Item2 + " " + UniteMesure + " " + AnneeJour + " " + (Month)(Mois - 1) + " " + statJour.Min.Item1; } Grid3text.Text = (Month)(Mois - 1) + "," + AnneeJour; Btn3text.Text = (Month)(Mois - 1) + "," + AnneeJour; } }