Skip to content

Instantly share code, notes, and snippets.

@alexismp
Last active June 11, 2019 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexismp/0902d00a2ba8e010d30c369aa514eadf to your computer and use it in GitHub Desktop.
Save alexismp/0902d00a2ba8e010d30c369aa514eadf to your computer and use it in GitHub Desktop.
csv2sheet style headers
function setColumnStyle(sheetsAPI, sheetId) {
return new Promise((resolve, reject) => {
const setStyleParams = {
spreadsheetId: process.env.SPREADSHEET_ID,
resource: {
requests: [
{
repeatCell: {
range: {
sheetId: sheetId,
startRowIndex: 0,
endRowIndex: 1
},
cell: {
userEnteredFormat: {
textFormat: {
fontSize: 11,
bold: true
}
}
},
fields: "userEnteredFormat(textFormat)"
}
}
]
}
};
sheetsAPI.spreadsheets.batchUpdate(setStyleParams, function(err, response) {
if (err) {
reject("The Sheets API returned an error: " + err);
} else {
console.log("Colums style set for sheetId: " + sheetId);
resolve();
}
}
);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment