# C1.C1Excel.XLSheet.Clone

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_C1Excel_XLSheet_Clone_" data-uid="C1.C1Excel.XLSheet.Clone*">Clone Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_C1Excel_XLSheet_Clone_" data-uid="C1.C1Excel.XLSheet.Clone*"></a>
<h4 id="C1_C1Excel_XLSheet_Clone" data-uid="C1.C1Excel.XLSheet.Clone">Clone()</h4>
<div class="markdown level1 summary"><p>Creates a copy of this sheet.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public XLSheet Clone()</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function Clone() As XLSheet</code></pre>
</div>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.C1Excel.XLSheet.html">XLSheet</a></td>
      <td><p>A new <a class="xref" href="C1.C1Excel.XLSheet.html">XLSheet</a> object with the same contents and formatting as this sheet.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_C1Excel_XLSheet_Clone_remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>After cloning a sheet, you must rename it and then add it to the book (duplicate names are not
allowed).</p>
<p>This method is useful for applications that generate books with a large number of similar sheets.</p>
</div>
<h5 id="C1_C1Excel_XLSheet_Clone_examples">Examples</h5>
<p>The code below loads a book that contains a template sheet, creates 12 copies of that sheet, removes the
template sheet, then saves the file with a new name.</p>
<pre><code class="lang-csharp">// load book with template sheet
_c1xl.Load(@"c:\temp\template.xls");

// create 12 copies of the template sheet
XLSheet templateSheet = _c1xl.Sheets["Template"];
for (int month = 1; month &lt;= 12; month++)
{
  XLSheet newSheet = templateSheet.Clone();
  newSheet.Name = month.ToString(); // rename clone
  newSheet[0,0].Value = month;      // make changes
  _c1xl.Sheets.Add(newSheet);       // add clone to book
}

// remove the template sheet and save with new name
_c1xl.Sheets.Remove("Template");
_c1xl.Save(@"C:\temp\expense_report.xls");</code></pre>

</div>
