How Convert Json string to Excel in Xamarin Forms

AsVAsV USMember ✭✭✭
edited September 2018 in Xamarin.Forms

Hi ,I am trying to convert Json data to Excel in xamarin forms for that I am trying like

        using (var client = new HttpClient())
        using (var formData = new MultipartFormDataContent())
            var fileFormat = "xlsx";
            formData.Add(new StringContent("TestDocument"), "FileName");
            formData.Add(new StringContent(fileFormat), "FileFormat");
            formData.Add(new StringContent(JsonConvert.SerializeObject(jsonData)), "Data");
            //Call WebAPI to get Excel  
            var response = client.PostAsync("", formData).Result;
            if (!response.IsSuccessStatusCode)
                DisplayAlert("Error!", "", "Ok");
            var tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            if (!Directory.Exists(tempPath))
            //Save Excel to Tem directory.  
            var tempFilePath = Path.Combine(tempPath, string.Format("{0}.{1}", "Test", fileFormat));
            string newFileName = string.Empty;
            using (var newFile = File.Create(tempFilePath))
                newFileName = newFile.Name;

It is converting Json to excel with no data.What I am doing wrong or is there any new way to covert can anyone help me for this?

Sign In or Register to comment.