Home > Software design >  Altering textFormat of a cell breaks hyperlinks in Google sheet
Altering textFormat of a cell breaks hyperlinks in Google sheet

Time:11-05

I'm creating a Google Sheet adding content like: =HYPERLINK("https://example.com","Example")

Which works fine until I try to alter the cell -> userEnteredFormat -> textFormat

Here's an example of broken links

Cell formatting works (see the second sheet).

If I change my config from

                  "cell" => [
                            "userEnteredFormat" => [
                                "backgroundColor" => [
                                    "red" => 1.0,
                                    "green" => 1.0,
                                    "blue" => 1.0
                                ],
                                "horizontalAlignment" => "LEFT",
                                "wrapStrategy" => "WRAP",
                                "textFormat" => [
                                    "foregroundColor" => [
                                        "red" => 0.0,
                                        "green" => 0.0,
                                        "blue" => 0.5
                                    ],
                                    "fontSize" => 10,
                                    "bold" => true
                                ]
                            ]
                        ],
                        "fields" => "userEnteredFormat(backgroundColor,textFormat,horizontalAlignment,wrapStrategy)"

To

                  "cell" => [
                            "userEnteredFormat" => [
                                "backgroundColor" => [
                                    "red" => 1.0,
                                    "green" => 1.0,
                                    "blue" => 1.0
                                ],
                                "horizontalAlignment" => "LEFT",
                                "wrapStrategy" => "WRAP",
                                "textFormat" => [
                                ]
                            ]
                        ],
                        "fields" => "userEnteredFormat(backgroundColor,textFormat,horizontalAlignment,wrapStrategy)"

The issue goes away.

CodePudding user response:

I thought that from your request body, I thought that the reason of your issue might be due to fields. So, in your situation, how about modifying the value of fields as follows?

From:

"fields" => "userEnteredFormat(backgroundColor,textFormat,horizontalAlignment,wrapStrategy)"

To:

"fields" => "userEnteredFormat(backgroundColor,textFormat(foregroundColor,fontSize,bold),horizontalAlignment,wrapStrategy)"

Reference:

  • Related