<?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: check if excel worksheet exsists in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/check-if-excel-worksheet-exsists/m-p/40253#M23563</link>
    <description>&lt;P&gt;that works good.&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
    <pubDate>Sun, 11 Jun 2017 15:40:58 GMT</pubDate>
    <dc:creator>Amir_y</dc:creator>
    <dc:date>2017-06-11T15:40:58Z</dc:date>
    <item>
      <title>check if excel worksheet exsists</title>
      <link>https://community.jmp.com/t5/Discussions/check-if-excel-worksheet-exsists/m-p/40250#M23560</link>
      <description>&lt;P&gt;I would like to write JMP script which try to open specific worksheet from excel.&lt;/P&gt;&lt;P&gt;The problem is if one of my excel files not including the requested worksheet, then the JMP script crush .&lt;/P&gt;&lt;P&gt;I need&amp;nbsp;advice how can I prevent it? (I mean, check before open the excel, if it including the requested worksheet..)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this si my code:&lt;/P&gt;&lt;P&gt;add_to_DB = function({file_path, sheet, header_line, data_line},&lt;BR /&gt;&lt;BR /&gt;new_dt = Open(&lt;BR /&gt;file_path,&lt;BR /&gt;Worksheets( sheet ),&lt;BR /&gt;Worksheet Settings(&lt;BR /&gt;Headers Start on Row( header_line ),&lt;BR /&gt;Data Starts on Row( data_line ))&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2017 11:28:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/check-if-excel-worksheet-exsists/m-p/40250#M23560</guid>
      <dc:creator>Amir_y</dc:creator>
      <dc:date>2017-06-11T11:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: check if excel worksheet exsists</title>
      <link>https://community.jmp.com/t5/Discussions/check-if-excel-worksheet-exsists/m-p/40251#M23561</link>
      <description>&lt;P&gt;I doubt that&amp;nbsp;there was any &lt;EM&gt;crash&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;I don't know of any way for a script to check for the presence of a particular sheet in an Excel workbook or for specific content in any other external file type. So your solution won't work.&lt;/P&gt;
&lt;P&gt;Error conditions like yours happen in real life all the time. There are ways to deal with them in the script. Have you learned JSL yet? You should read &lt;STRONG&gt;Help&lt;/STRONG&gt; &amp;gt; &lt;STRONG&gt;Books&lt;/STRONG&gt; &amp;gt; &lt;STRONG&gt;Scripting Guide&lt;/STRONG&gt;. Chapter 8 in the current version covers &lt;EM&gt;Programming Methods&lt;/EM&gt; such as error handling.&lt;/P&gt;
&lt;P&gt;Are you sure that your code works when the desired sheet is present?&lt;/P&gt;
&lt;P&gt;One way is to pay attention to what the Open() function returns. What is returned to the log? Did you look at it? You could store the result in a variable and then test whether&amp;nbsp;it was successful.&lt;/P&gt;
&lt;P&gt;Alternatively, you could use the built-in error handling mechanism to trap the error condition. In your case, this mechanism would work like this example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Try(
	new_dt = Open(
		file_path,
		Worksheets( sheet ),
		Worksheet Settings( Headers Start on Row( header_line ), Data Starts on Row( data_line ) )
	),
	// code in case Open() fails
);;

// code in case Open() succeeds&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2017 12:40:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/check-if-excel-worksheet-exsists/m-p/40251#M23561</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2017-06-11T12:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: check if excel worksheet exsists</title>
      <link>https://community.jmp.com/t5/Discussions/check-if-excel-worksheet-exsists/m-p/40253#M23563</link>
      <description>&lt;P&gt;that works good.&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2017 15:40:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/check-if-excel-worksheet-exsists/m-p/40253#M23563</guid>
      <dc:creator>Amir_y</dc:creator>
      <dc:date>2017-06-11T15:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: check if excel worksheet exsists</title>
      <link>https://community.jmp.com/t5/Discussions/check-if-excel-worksheet-exsists/m-p/40272#M23578</link>
      <description>&lt;P&gt;If you ever want to find a list of sheetnames that DO exist within the Excel workbook, you can use something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sheetList = Get Excel Worksheets( "$SAMPLE_IMPORT_DATA\Team Results.xlsx" );&lt;BR /&gt;Show( sheetList );&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Brian Corcoran&lt;/P&gt;
&lt;P&gt;JMP Development&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 12:37:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/check-if-excel-worksheet-exsists/m-p/40272#M23578</guid>
      <dc:creator>briancorcoran</dc:creator>
      <dc:date>2017-06-12T12:37:37Z</dc:date>
    </item>
  </channel>
</rss>

