Skip to content

Instantly share code, notes, and snippets.

@ryonakae
Last active December 3, 2018 05:01
Show Gist options
  • Save ryonakae/02e1b83fc324758b598a6714b3b68079 to your computer and use it in GitHub Desktop.
Save ryonakae/02e1b83fc324758b598a6714b3b68079 to your computer and use it in GitHub Desktop.
node.jsでスプレッドシートのgidをworksheetidに変換
function gid_to_wid(gid) {
const xorval = gid > 31578 ? 474 : 31578
const letter = gid > 31578 ? 'o' : ''
const wid = letter + parseInt((gid ^ xorval)).toString(36)
console.log('gid', gid)
console.log('xorval', xorval)
console.log('letter', letter)
console.log('worksheetid', wid)
}
gid_to_wid(process.argv[2])
@ryonakae
Copy link
Author

ryonakae commented Dec 3, 2018

gidが12345だとして、

$ node gid_to_wid.js 12345

すると、

gid 12345
xorval 31578
letter
worksheetid ew3

のように表示される

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment