<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Scripting: save multiple data table to multiple sheets in Excel in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Scripting-save-multiple-data-table-to-multiple-sheets-in-Excel/m-p/562387#M77540</link>
    <description>&lt;P&gt;This issue you are having is with 2 of the elements that you are attempting to pass to the Create Excel Workbook&lt;/P&gt;
&lt;P&gt;The&amp;nbsp; third element in Create Excell Workbook function, need to be a list.&amp;nbsp; In your case,&amp;nbsp; the specification is not a list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Element 2 documentation indicates that what is required is "List of open tables".&amp;nbsp; While your specification of&lt;/P&gt;
&lt;P&gt;&amp;nbsp;While the returned element from the Summarize() function, GroupBy, is a list, GroupBy[1] is a string variable.&amp;nbsp; You need to do something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;tempList = {};
insert into( tempList, GroupBy[1]);
Create Excel Workbook ("$DESKTOP/Untitled1.xlsx", {dt2}, tempList);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 31 Oct 2022 05:35:20 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2022-10-31T05:35:20Z</dc:date>
    <item>
      <title>Scripting: save multiple data table to multiple sheets in Excel</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-save-multiple-data-table-to-multiple-sheets-in-Excel/m-p/562153#M77519</link>
      <description>&lt;P&gt;I like to save multiple datatables, each to an individual sheet, in a single Excel file?&lt;/P&gt;&lt;P&gt;What is the script to achieved that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried "append", but it did not work&lt;/P&gt;&lt;P&gt;dt&amp;lt;&amp;lt; Save as("$DESKTOP/Untitled73.xlsx", append);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:01:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-save-multiple-data-table-to-multiple-sheets-in-Excel/m-p/562153#M77519</guid>
      <dc:creator>GroupSquareWolf</dc:creator>
      <dc:date>2023-06-09T16:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting: save multiple data table to multiple sheets in Excel</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-save-multiple-data-table-to-multiple-sheets-in-Excel/m-p/562164#M77522</link>
      <description>&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/16.2/#page/jmp/create-excel-workbooks.shtml?os=win&amp;amp;source=application#ww1236905" target="_self"&gt;Create Excel Workbooks&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1667057701645.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/46729iD19198112D5A4C1E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1667057701645.png" alt="jthi_0-1667057701645.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Oct 2022 15:35:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-save-multiple-data-table-to-multiple-sheets-in-Excel/m-p/562164#M77522</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-10-29T15:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting: save multiple data table to multiple sheets in Excel</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-save-multiple-data-table-to-multiple-sheets-in-Excel/m-p/562182#M77523</link>
      <description>&lt;P&gt;The answer to your question comes from the Scripting Indes&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1667058459806.png" style="width: 903px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/46730iCEC45900000F703E/image-dimensions/903x429?v=v2" width="903" height="429" role="button" title="txnelson_0-1667058459806.png" alt="txnelson_0-1667058459806.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Here is one of the examples from that entry&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
Open( "$SAMPLE_DATA/Abrasion.jmp" );
Create Excel Workbook(
	"$TEMP/MyWorkbook.xlsx",
	{"Big Class", "Abrasion"},
	{"Big", "Abrasive"}
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 29 Oct 2022 15:48:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-save-multiple-data-table-to-multiple-sheets-in-Excel/m-p/562182#M77523</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-10-29T15:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting: save multiple data table to multiple sheets in Excel</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-save-multiple-data-table-to-multiple-sheets-in-Excel/m-p/562368#M77539</link>
      <description>&lt;P&gt;Thank you for pointing out the Srcipting index, it is really helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A further question: does the "list of the worksheet names" have to be strings? Can they be string variables?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GroupSquareWolf_2-1667191186373.png" style="width: 469px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/46742i850C220719C9D9FF/image-dimensions/469x46?v=v2" width="469" height="46" role="button" title="GroupSquareWolf_2-1667191186373.png" alt="GroupSquareWolf_2-1667191186373.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example I am struggling with:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GroupSquareWolf_1-1667190873534.png" style="width: 159px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/46741iB8C22C06002B59B8/image-dimensions/159x163?v=v2" width="159" height="163" role="button" title="GroupSquareWolf_1-1667190873534.png" alt="GroupSquareWolf_1-1667190873534.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The script below creates three datatables based on :Column 2 values, then save three separate sheets in one Excel files. I would like to name each worksheet based on :Column 2 values, but when I put GroupBy variable as the worksheet names (the red script below), it does not assign :Column 2 value to each worksheet.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = current datatable();

Summarize (dt, GroupBy = By (:Column 2) );

For ( i=1, i&amp;lt;= N items (GroupBy), i++,

dt&amp;lt;&amp;lt; select where (:Column 2 == GroupBy [i]);

dt2= dt &amp;lt;&amp;lt; subset (

	Selected Rows( 1 ),
	Selected columns only( 0 )
);

show (dt2);
show (GroupBy[i]);
&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Create Excel Workbook ("$DESKTOP/Untitled1.xlsx", {dt2}, GroupBy[i]);
&lt;FONT color="#000000"&gt;);&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 04:44:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-save-multiple-data-table-to-multiple-sheets-in-Excel/m-p/562368#M77539</guid>
      <dc:creator>GroupSquareWolf</dc:creator>
      <dc:date>2022-10-31T04:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting: save multiple data table to multiple sheets in Excel</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-save-multiple-data-table-to-multiple-sheets-in-Excel/m-p/562387#M77540</link>
      <description>&lt;P&gt;This issue you are having is with 2 of the elements that you are attempting to pass to the Create Excel Workbook&lt;/P&gt;
&lt;P&gt;The&amp;nbsp; third element in Create Excell Workbook function, need to be a list.&amp;nbsp; In your case,&amp;nbsp; the specification is not a list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Element 2 documentation indicates that what is required is "List of open tables".&amp;nbsp; While your specification of&lt;/P&gt;
&lt;P&gt;&amp;nbsp;While the returned element from the Summarize() function, GroupBy, is a list, GroupBy[1] is a string variable.&amp;nbsp; You need to do something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;tempList = {};
insert into( tempList, GroupBy[1]);
Create Excel Workbook ("$DESKTOP/Untitled1.xlsx", {dt2}, tempList);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 05:35:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-save-multiple-data-table-to-multiple-sheets-in-Excel/m-p/562387#M77540</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-10-31T05:35:20Z</dc:date>
    </item>
  </channel>
</rss>

