1

I'm trying to set a background color to the cells in Google Sheets.

Hello! I'm having problems inserting a row. I want to set a background color to it once added, but I'm not sure how to go about doing that. I did a lot of research, but I still don't understand it. I'm trying to write the following section of code. Thank you.

if(!oldMember._roles.includes(process.env.PFA_ID.toString()) &&
    newMember._roles.includes(process.env.PFA_ID.toString()))
{
    newMember.roles.cache.forEach(role => {
        if (role.id.toString() == process.env.PFA_ID && !oldMember.roles.cache.has(role.id) && rolesList.includes(role.name))
        {
            
            googleSheets.spreadsheets.values.append({
                auth,
                spreadsheetId,
                range: 'RANGOS',
                valueInputOption: 'USER_ENTERED',
                resource: {
                    values: [
                        ['', newMember.nickname, newMember.id, new Date().toLocaleString().split(',')[0]] // Se le agrega con el nombre que esté... cuando se lo cambie será un update
                    ],
                    backgroundColorStyle: {
                    }
                },
            })
        }
    })
}
2
  • Can you provide your script as a text instead of an image? Commented Jan 10, 2023 at 3:01
  • Now, I noticed that you had updated your question. I apologize for this. About I want it to be added with a background color, where cells do you want to change the background colors? And, what color do you want to set to the cells? Commented Jan 10, 2023 at 4:43

1 Answer 1

0

I believe you can also find the answer to this similar thread. https://stackoverflow.com/a/44026927/20970426

Also, feel free to check this Documentation.

Sign up to request clarification or add additional context in comments.

2 Comments

A link to a solution is welcome, but please ensure your answer is useful without it: add context around the link so your fellow users will have some idea what it is and why it is there, then quote the most relevant part of the page you are linking to in case the target page is unavailable.
Oh you're right. That makes sense.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.