title: Export array of objects into Excel using Javascript
body: <p>I'm writing a client side method, that creates an array of objects.I open an existing excel to write the values from the array. I get the values using getProperty and store in a variable.
  When I try to write those in the excel, I get &quot;event handler failed with message&quot;;&quot; &quot;.</p>
  <p>Code:</p>
  <pre class="lang-js prettyprint-override"><code>var getItemtoExcel = document.thisItem.newItem(&quot;ToExcel&quot;, &quot;get&quot;);
  getItemtoExcel = getItemtoExcel.apply();
  
  var arrToExcel = Array();
  for (var j = 0; j &lt; getItemtoExcel.getItemCount(); j++) {
      var gotItemForExcel = getItemtoExcel.getItemByIndex(j);
      arrToExcel.push(gotItemForExcel);
  }
  
  var Excel = new ActiveXObject(&quot;Excel.Application&quot;);
  Excel.Visible = true;
  Excel.Workbooks.Open(&quot;C:\\test.xls&quot;);
  
  var offset = 0;
  var row = 2;
  for (var c = 0; c &lt; arrToExcel.length; c++) {
      var createExcel = arrToExcel[c];
      var Number = createExcel.getProperty(&quot;nb&quot;);
      var Type = createExcel.getProperty(&quot;type&quot;);
      var Code = createExcel.getProperty(&quot;code&quot;);
      var State = createExcel.getProperty(&quot;state&quot;);
  
      Excel.Worksheets(&quot;sheet11&quot;).Range(&quot;A&quot; &amp; row + 1 + offset).Value = Number;
      Excel.Worksheets(&quot;sheet11&quot;).Range(&quot;B&quot; &amp; row + 1 + offset).Value = Type;
      Excel.Worksheets(&quot;sheet11&quot;).Range(&quot;C&quot; &amp; row + 1 + offset).Value = Code;
      Excel.Worksheets(&quot;sheet11&quot;).Range(&quot;D&quot; &amp; row + 1 + offset).Value = State;
      row = row + 1;
  }
  
  offset = offset + 1;
  return this;
  </code></pre>
  <p>document.thisItem.newItem() is from ARASPLM. Its the standard used to call an ItemType(Item) in ARAS</p>