Home > OS >  Google Sheets API Response IList object to String in C#
Google Sheets API Response IList object to String in C#

Time:10-27

static string StringEntryRequest()
    {
        var range = "NET!A1";
        var request = service.Spreadsheets.Values.Get(spreadsheetId, range);
            Console.WriteLine("Execute");
        ValueRange response = request.Execute();
            Console.WriteLine("Execute complete");
        IList<IList<Object>> values = response.Values;
            string i = values.ToString();
        return (i);
    }

I have created a Application in C# which should return the Value of a Cell in a Spreedsheet. The Problem is that i can't convett the IList Object into a String. My Current code works fine but just the conversion from IList to String seems impossible to me.

CodePudding user response:

Welecom to SO, did your try that ?

    Private Function ConvertToListOfString(lstObject As IList(Of Object)) As List(Of String)
    Return lstObject.Select(Function(e) e.ToString()).ToList()
End Function

CodePudding user response:

I found a way to convert the given IList into a String with the following Method:

        foreach (var value in values)
        {  
            string i = value[0].ToString();
            return i;
        }
  • Related