简体   繁体   中英

How Can I create a Google spreadsheet with two sheets in javascript using Google sheets API?

I'm trying to create a Google Spreadsheet with two sheets or 'tabs' Using javascript. I can Create a sheet and add a title to a tab, but I can only create one tab. I have tried to use the addSheet property as well and it simply over-writes existing sheet. This is the data I'm trying to send as an example:

var data = {
  properties: {
    title: 'Data Sheet'
  },

  sheets: [{
    properties: {
      title: 'data A',
    },
    properties: {
      title: 'data B',
    }

  }]
};

I was missing additional brackets around my data. Simple mistake:

var data = { properties: { title: 'Data Sheet' },

                    sheets : [
                        {
                            properties: {
                                title: 'data A',
                            }
                        },
                        {
                            properties: {
                                title: 'data B',
                            }
                        }
                    ]
                };

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM