Forum Discussion

torus's avatar
torus
Frequent Contributor
2 years ago
Solved

Excel: how do you change sheet name in Excel file

How do you change the name of a sheet in excel? This is what I have so far but can't find the method which changes the sheet 'Title'. Please do not delete this question:

 

<SPAN class="token keyword">function</SPAN> <SPAN class="token function">changeExcelTabName</SPAN><SPAN class="token punctuation">(</SPAN><SPAN class="token punctuation">)</SPAN>
<SPAN class="token punctuation">{</SPAN>
  <SPAN class="token keyword">var</SPAN> excelFile <SPAN class="token operator">=</SPAN> Excel<SPAN class="token punctuation">.</SPAN><SPAN class="token function">Open</SPAN><SPAN class="token punctuation">(</SPAN><SPAN class="token string">"C:\\Users\\chk\\Downloads\\Task groups with no tasks_2024_3_11 16_59_34.xlsx"</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">;</SPAN>
  excelFile<SPAN class="token punctuation">.</SPAN><SPAN class="token function">SheetByIndex</SPAN><SPAN class="token punctuation">(</SPAN><SPAN class="token number">0</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">.</SPAN>Title
  <SPAN class="token operator"><</SPAN>the code to change sheet title would go here<SPAN class="token operator">></SPAN>
  excelFile<SPAN class="token punctuation">.</SPAN><SPAN class="token function">Save</SPAN><SPAN class="token punctuation">(</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">;</SPAN>
<SPAN class="token punctuation">}</SPAN>