How to hide column with the excel javascript api

Yaco 1 Reputation point

I use the JavaScript API with Excel.
I want to hide a couple of columns.
I don't understant witch syntax to use. My code doesn't work :

export const test = () => { => {
    const sheet = context.workbook.worksheets.getItem("Sample");

Where to set 'true' ?
Thanks !

JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
900 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,575 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Martin 1 Reputation point

    I found it working this way:

    async function hideUnhideColumnAsync(hidden) {
            return (context) => {
    let targetSheet = context
    targetSheet.getRange('A:A').columnHidden = hidden;
    return await context.sync();
    0 comments No comments