title: How to customize date format when creating excel cells through javascript (activexobject)?
body: <p>I'm trying to convert an HTML table to Excel in Javascript using new <code>ActiveXObject("Excel.application")</code>. Bascially I loop through table cells and insert the value to the corresponding cell in excel:</p>
  
  <pre><code>//for each table cell
  oSheet.Cells(x,y).value = cell.innerText;
  </code></pre>
  
  <p>The problem is that when the cell is in date format of 'dd-mm-yyyy' (e.g. 10-09-2008), excel would read as 'mm-dd-yyyy' (i.e. 09 Oct 2008). I tried to specify <code>NumberFormat</code> like:</p>
  
  <pre><code>oSheet.Cells(x,y).NumberFormat = 'dd-mm-yyyy';
  </code></pre>
  
  <p>But, it has no effect. It seems that this only affect how excel <strong>display the value, not parse</strong>. My only solution now is to swap the date like:</p>
  
  <pre><code>var txt = cell.innerText;
  if(/^(\d\d)-(\d\d)-\d\d\d\d$/.test(txt)) txt = txt.replace(/^(\d\d)-(\d\d)/,'$2-$1');
  </code></pre>
  
  <p>But, I'm worrying that it is not generic and a differnt machine setting would fail this.</p>
  
  <p>Is there a way to specific how excel <strong>parse</strong> the input value?</p>