title: Worksheet.SaveAs Method Saves All Sheets
body: <p>Using C# to write a method that takes a single worksheet out of a workbook and saves it as HTML. </p>
  
  <p>I am using the Worksheet.SaveAs method as described on <a href="http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.worksheet.saveas(v=vs.110).aspx" rel="nofollow">MSDN</a>.</p>
  
  <p>However, when I look at the output it has gone and saved all of the worksheets within the workbook, not just the one I selected. It's as though Worksheet.SaveAs and Workbook.SaveAs just do the same thing.</p>
  
  <p>Simplified code:</p>
  
  <pre><code>public static void saveSingleSheetAsHTML(string workbook, string destination, string sheetName)
  {
      Application excel = new Application();
      excel.Workbooks.Open(Filename: workbook);
      Microsoft.Office.Interop.Excel._Worksheet worksheet = excel.Worksheets[sheetName];
      var format = Microsoft.Office.Interop.Excel.XlFileFormat.xlHtml;
      worksheet.SaveAs(destination, format);
  }
  </code></pre>
  
  <p>Now when I open the resulting HTML file it has only gone and exported the entire workbook, not the sheet.</p>