Remove auto-link formatting from Google Sheet via api - google-sheets-api

When using Google Sheets Api to create automated reports I've found that any string that ends with ".com" automatically gets formatted as a link (I've attached a picture). I'd like to remove this formatting via the api, Is this possible?
Two examples of the autolink formatting

You can change the hyperlink format to the plain text format using "hyperlinkDisplayType". The endpoint and request body are as follows. As a sample, the request body removes the hyperlink format of cells "A1:A3". I thought that from the image of your question, repeatCell might be suitable for your situation.
Endpoint :
POST https://sheets.googleapis.com/v4/spreadsheets/### spreadsheet ID ###:batchUpdate
Request body :
{
"requests":
[
{
"repeatCell":
{
"cell":
{
"userEnteredFormat":
{
"hyperlinkDisplayType": "PLAIN_TEXT"
}
},
"fields": "userEnteredFormat.hyperlinkDisplayType",
"range":
{
"sheetId": sheetId,
"startRowIndex": 0,
"endRowIndex": 3,
"startColumnIndex": 0,
"endColumnIndex": 1
}
}
}
]
}
Note :
This answer supposes that you can use Sheets API.
Reference :
HyperlinkDisplayType
RepeatCellRequest
If I misunderstand your question, I'm sorry.

Related

How to get the link data with pretty text in it from Google Sheet API

I'm getting data from google sheet in CSV format. But when the sheet has a Hyperlink in its cell, like =Hyperlink("URL", "pretty text"), the google sheet only gives me the pretty text not the link, So my question is how can I get both links & pretty text from google sheet.
Thanks for helping me
You will have to make use of the valueRenderOption parameter when making the spreadsheets.values.get API call.
Assuming your cell looks like this:
You can retrieve the following values using different values for the valueRenderOption parameter as this one will determine how values are rendered in the output.
1. If valueRenderOption is FORMATTED_VALUE (which is the default value when making the API call):
GET https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID/values/A1?valueRenderOption=FORMATTED_VALUE
Then the response will look like this:
{
"range": "Sheet1!A1",
"majorDimension": "ROWS",
"values": [
[
"pretty text"
]
]
}
2. If valueRenderOption is UNFORMATTED_VALUE:
GET https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID/values/A1?valueRenderOption=UNFORMATTED_VALUE
Then the response will look like this:
{
"range": "Sheet1!A1",
"majorDimension": "ROWS",
"values": [
[
"pretty text"
]
]
}
3. If valueRenderOption is FORMULA:
GET https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID/values/A1?valueRenderOption=FORMULA
Then the response will look like this:
{
"range": "Sheet1!A1",
"majorDimension": "ROWS",
"values": [
[
"=HYPERLINK(\"URL\", \"pretty text\")"
]
]
}
Therefore, depending on the exact result you want to achieve, it would be best to use the FORMULA parameter as this will retrieve the formula with its link and value as well. This might require some string processing if you simply want the link and its value.
Reference
Sheets API spreadsheets.values.get;
Sheets API ValueRenderOption.

Can we create multiple sheets using Google Sheet API the way we create manually?

I want to add multiple sheets with different values under a google sheet but I cannot find it anywhere. Is it possible?
Your question is quite unclear. In case you're looking for a python way of adding new sheets, then you can refer to google sheets API documentation to Add sheets. You may use the Batch Update and Add Sheet request
{
"requests": [
{
"addSheet": {
"properties": {
"title": <<Your Sheet Name Goes Here>>,
"gridProperties": {
"rowCount": 20,
"columnCount": 12
},
"tabColor": {
"red": 1.0,
"green": 0.3,
"blue": 0.4
}
}
}
}
]
}

Google Vision Text Detection returns too much unnecesary data

When using Google Vision to run text detection on a menu, the response from their API is way too large and returns way too much data that I don't need. I just want the text from the menu, not all the coordinates that come with the response. I can't find anything about narrowing down the response in any documentation i've read. Does someone know how to specify what fields get returned in the response?
Heres my request:
POST: https://vision.googleapis.com/v1/images:annotate?key=<MY_KEY>
BODY:
{
"requests": [
{
"image": {
"content": "...base64-encoded-image-content..."
},
"features": [
{
"type": "TEXT_DETECTION"
}
]
}
]
}
I figured it out. I could not find any documentation on how to do this, I had to just guess for like half an hour. If someone knows of any documentation on this let me know.
Anyway you can use the "fields" parameter to narrow down the response like so:
POST: https://vision.googleapis.com/v1/images:annotate?key=<MY_KEY>&fields=responses.fullTextAnnotation.text
This will only return the menu text from the Google Vision text detection API

How to apply filters in Googlesheet API using Java

I have an API built along with Google Sheet API which interact with my google sheet and returns all the data. Is there a possible way to apply filter in google sheet and get only the data available to the filter(As like how we do filter in google sheet manually)?
You may check the following:
DataFilter that describes what data should be selected or returned from a request.
{
// Union field filter can be only one of the following:
"developerMetadataLookup": {
object(DeveloperMetadataLookup)
},
"a1Range": string,
"gridRange": {
object(GridRange)
},
// End of list of possible types for union field filter.
}
FilterCriteria for showing/hiding rows in a filter or filter view.
{
"hiddenValues": [
string
],
"condition": {
object(BooleanCondition)
},
}
PivotFilterCriteria for showing/hiding rows in a pivot table.
{
"visibleValues": [
string
],
}
Hope this helps!

How to get response from Google+ Share API about whether user shared link or not

I want to check whether the user shared my content in google plus or not, I tried onendinteraction callback but user may click close button instead of share button so i need to detect user originally shared content or not?
Just noticed this linked question. I answered it on another post but here it is again -
According to Google Developer page for their web platform, it seems you can tap into the current users activities list using a javascript code similar to -
var request = gapi.client.plus.activities.list({
'userId' : 'me',
'collection' : 'public'
});
request.execute(function(resp) {
var numItems = resp.items.length;
for (var i = 0; i < numItems; i++) {
console.log('ID: ' + resp.items[i].id + ' Content: ' +
resp.items[i].object.content);
}
});
The online tool to generate and test the query end point is there on the Developer Page
Generate and append a custom query string to the end of the link your user is sharing, the JSON returned from the end point can be parsed to check if that particular link has been shared on the users activity stream.
The JSON returned looks like this -
{
"items": [
{
"title": "",
"published": "2015-06-12T16:39:11.176Z",
"url": "https://plus.google.com/+UserID/posts/PostID",
"object": {
"content": "",
"attachments": [
{
"objectType": "article",
"url": "http://www.example.com"
}
]
}
}
]
}
If the link with the custom query is there in the attachments section of one of the returned items,Voila! Its been shared.