public void SavePlots() { using (ExcelEngine excelEngine = new ExcelEngine()) { excelEngine.Excel.DefaultVersion = ExcelVersion.Excel2013; IWorkbook workbook = excelEngine.Excel.Workbooks.Create(1); workbook.Version = ExcelVersion.Excel97to2003; for (int y = 0; y < ((List <Plot>)Application.Current.Properties["Plots"]).Count(); y++) { Plot thisPlot = ((List <Plot>)Application.Current.Properties["Plots"]).ElementAt(y); workbook.Worksheets.Create(thisPlot.GetName()); IWorksheet worksheet = workbook.Worksheets[y + 1]; worksheet.SetValue(1, 1, "Name"); worksheet.SetValue(2, 1, "Co-ordinates"); worksheet.SetValue(1, 4, "Owner"); worksheet.SetValue(2, 4, "Location"); worksheet.SetValue(3, 4, "Year Planted"); worksheet.SetValue(4, 4, "Comments"); if (thisPlot.Owner != null) { worksheet.SetValue(1, 5, thisPlot.Owner); } if (thisPlot.NearestTown != null) { worksheet.SetValue(2, 5, thisPlot.NearestTown); } if (thisPlot.Describe != null) { worksheet.SetValue(4, 5, thisPlot.Describe); } worksheet.SetValue(3, 5, thisPlot.YearPlanted.ToString()); worksheet.SetValue(1, 2, thisPlot.GetName()); worksheet.SetValue(2, 2, thisPlot.GetTag()[0].ToString()); worksheet.SetValue(2, 3, thisPlot.GetTag()[1].ToString()); worksheet.SetValue(3, 1, "Pricing Name"); // if (thisPlot.GetRange() != null){ // worksheet.SetValue(3, 2, thisPlot.GetRange().GetName()); // } worksheet.SetValue(3, 3, thisPlot.GetPolygon().Count.ToString()); worksheet.SetValue(4, 1, "Border Co-ordinates"); worksheet.Range["$A$4:$B$4"].Merge(); for (int x = 0; x < thisPlot.GetPolygon().Count; x++) { worksheet.SetValue(5 + x, 1, thisPlot.GetPolygon().ElementAt(x).Latitude.ToString()); worksheet.SetValue(5 + x, 2, thisPlot.GetPolygon().ElementAt(x).Longitude.ToString()); } } workbook.Worksheets[0].Remove(); MemoryStream stream = new MemoryStream(); workbook.SaveAs(stream); workbook.Close(); Xamarin.Forms.DependencyService.Get <ISave>().Save("Plots.xls", "application/msexcel", stream); } }
public void Kamel() { string output = "<?xml version =\"1.0\" encoding=\"UTF-8\"?>\n<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n<Document>"; for (int x = 0; x < ((List <Plot>)Application.Current.Properties["Plots"]).Count; x++) { Plot ThisPlot = ((List <Plot>)Application.Current.Properties["Plots"]).ElementAt(x); output += "\n<Placemark>\n<name>" + ThisPlot.GetName() + "</name>\n"; double[] tag = ((List <Plot>)Application.Current.Properties["Plots"]).ElementAt(x).GetTag(); output += "<description>\n"; if (ThisPlot.YearPlanted > 0) { output += AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("YPlant") + ": " + ThisPlot.YearPlanted.ToString() + "\n"; } List <Tree> TreeList = ThisPlot.getTrees(); int year = DateTime.Now.Year; output += "</description>"; output += "<Point>\n<coordinates>" + tag[1].ToString() + "," + tag[0].ToString() + "</coordinates>\n </Point>\n"; if (ThisPlot.GetPolygon().Count > 0) { output += "<Polygon><outerBoundaryIs><LinearRing><coordinates>\n"; for (int y = 0; y < ThisPlot.GetPolygon().Count; y++) { output += ThisPlot.GetPolygon().ElementAt(y).Longitude.ToString() + ", " + ThisPlot.GetPolygon().ElementAt(y).Latitude + ", 0.\n"; } output += " </coordinates></LinearRing></outerBoundaryIs></Polygon>\n<Style><PolyStyle><color>#a00000ff</color><outline>0</outline></PolyStyle></Style>\n</Placemark>"; } else { output += "</Placemark>"; } } output += "\n</Document>\n</kml>"; byte[] byteArray = Encoding.UTF8.GetBytes(output); MemoryStream stream = new MemoryStream(byteArray); Xamarin.Forms.DependencyService.Get <ISave>().Save("map.kml", "text/plain", stream); }