static public void GenerateXLS(string fileName, List<RoadMap> roadmaps, double conso, double gasCost) { Total total = new Total(); SpreadsheetDocument doc = new SpreadsheetDocument(); doc.ApplicationName = "PlanMyWay"; doc.Creator = "SuperBen"; doc.Company = "PlanMyWay & Co."; doc.Workbook.Sheets.FirstOrDefault().Sheet.Rows[0].Cells[1].SetValue("Consommation moyenne du véhicule"); doc.Workbook.Sheets.FirstOrDefault().Sheet.Rows[1].Cells[1].SetValue("Prix du carburant"); consoDefinition = doc.Workbook.Sheets.FirstOrDefault().Sheet.Rows[0].Cells[3]; gasCostDefinition = doc.Workbook.Sheets.FirstOrDefault().Sheet.Rows[1].Cells[3]; consoDefinition.SetValue(new Decimal(conso)); gasCostDefinition.SetValue(new Decimal(gasCost)); for (int i = 0; i< roadmaps.Count; i++) { if (i > 0) { total.Distance += "+"; total.Conso += "+"; total.CoutTotal += "+"; } total += SpreadSheetRoadmapGenerator.AddTableXLS(ref doc, roadmaps[i]); } SpreadSheetRoadmapGenerator.AddTotalXLS(ref doc, total); using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication()) using (Stream writeFile = new IsolatedStorageFileStream(fileName, FileMode.Create, file)) using (IStreamProvider storage = new ZipStreamProvider(writeFile)) { doc.Save(storage); } }
private async void Share_Click(object sender, RoutedEventArgs e) // Share { bool ReadOnly = true; for (int i = 0; i < Employees.Items.Count; i++) { EmployeeClass emp = (EmployeeClass)Employees.Items[i]; List<ArchyvedEmployeeClass> EC = new List<ArchyvedEmployeeClass>(){}; if (emp.IsChecked == true) { ReadOnly = false; SpreadsheetDocument doc = new SpreadsheetDocument(); doc.ApplicationName = "Goals_Results_Salary"; Create_Header(ref doc); Read_Workers(ref EC, emp); Create_Workers(ref doc, EC); using (var isoStore = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication()) { if (isoStore.FileExists("Goals_Results_Salary.xlsx")) isoStore.DeleteFile("Goals_Results_Salary.xlsx"); using (var s = isoStore.CreateFile("Goals_Results_Salary.xlsx")) using (IStreamProvider storage = new ZipStreamProvider(s)) doc.Save(storage); await Windows.System.Launcher.LaunchFileAsync(await ApplicationData.Current.LocalFolder.GetFileAsync("Goals_Results_Salary.xlsx")); } } } if (ReadOnly == true) { List<ArchyvedEmployeeClass> EC = new List<ArchyvedEmployeeClass>() { }; SpreadsheetDocument doc = new SpreadsheetDocument(); doc.ApplicationName = "Goals_Results_Salary"; Create_Header(ref doc); Read_Workers(ref EC); Create_Workers(ref doc, EC); using (var isoStore = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication()) { if (isoStore.FileExists("Goals_Results_Salary.xlsx")) isoStore.DeleteFile("Goals_Results_Salary.xlsx"); using (var s = isoStore.CreateFile("Goals_Results_Salary.xlsx")) using (IStreamProvider storage = new ZipStreamProvider(s)) doc.Save(storage); await Windows.System.Launcher.LaunchFileAsync(await ApplicationData.Current.LocalFolder.GetFileAsync("Goals_Results_Salary.xlsx")); } } KillAll(); SaveAll(); SaveKalba(System.Threading.Thread.CurrentThread.CurrentCulture.ToString()); }