# C1.WPF.Excel.C1XLBook.Save

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_WPF_Excel_C1XLBook_Save_" data-uid="C1.WPF.Excel.C1XLBook.Save*">Save Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_WPF_Excel_C1XLBook_Save_" data-uid="C1.WPF.Excel.C1XLBook.Save*"></a>
<h4 id="C1_WPF_Excel_C1XLBook_Save_System_String_" data-uid="C1.WPF.Excel.C1XLBook.Save(System.String)">Save(string)</h4>
<div class="markdown level1 summary"><p>Saves the worksheet to a file.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void Save(string fileName)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub Save(fileName As String)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">fileName</span></td>
      <td><p>Name of the file to save.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_WPF_Excel_C1XLBook_Save_System_String__remarks">Remarks</h5>
<div class="markdown level1 remarks"><pre><code>&lt;p&gt;The format used to save the file is automatically determined by the 
</code></pre>
<p>file name extension. &quot;Xlsx&quot; and &quot;zip&quot; files are saved as OpenXml; all others
are saved as Biff8 files (&quot;xls&quot;).</p>
<p>If the file can't be created, an exception is thrown.
This typically indicates that the file is currently open by another
application (such as Microsoft Excel).</p>
</div>


<a id="C1_WPF_Excel_C1XLBook_Save_" data-uid="C1.WPF.Excel.C1XLBook.Save*"></a>
<h4 id="C1_WPF_Excel_C1XLBook_Save_System_String_C1_WPF_Excel_FileFormat_" data-uid="C1.WPF.Excel.C1XLBook.Save(System.String,C1.WPF.Excel.FileFormat)">Save(string, FileFormat)</h4>
<div class="markdown level1 summary"><p>Saves the worksheet to a file.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void Save(string fileName, FileFormat format)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub Save(fileName As String, format As FileFormat)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">fileName</span></td>
      <td><p>Name of the file to save.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.WPF.Excel.FileFormat.html">FileFormat</a></td>
      <td><span class="parametername">format</span></td>
      <td><p><span class="xref">C1.WPF.Excel.C1XLBook.FileFormat</span> value that specifies the type of file to save.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_WPF_Excel_C1XLBook_Save_" data-uid="C1.WPF.Excel.C1XLBook.Save*"></a>
<h4 id="C1_WPF_Excel_C1XLBook_Save_System_IO_Stream_" data-uid="C1.WPF.Excel.C1XLBook.Save(System.IO.Stream)">Save(Stream)</h4>
<div class="markdown level1 summary"><p>Saves the worksheet into a stream.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void Save(Stream stream)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub Save(stream As Stream)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.stream">Stream</a></td>
      <td><span class="parametername">stream</span></td>
      <td><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.stream">Stream</a> where the worksheet is saved.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_WPF_Excel_C1XLBook_Save_System_IO_Stream__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method allows saving the workbook directly into streams without using
temporary files. Typical uses include saving books to web page response streams
or mail attachment streams.</p>
</div>
<h5 id="C1_WPF_Excel_C1XLBook_Save_System_IO_Stream__examples">Examples</h5>
<p>The code below saves a <a class="xref" href="C1.WPF.Excel.C1XLBook.html">C1XLBook</a> into a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.memorystream">MemoryStream</a>, clears
the book, then loads it back from the same stream.</p>
<pre><code class="lang-csharp">// save book into new MemoryStream
MemoryStream ms = new MemoryStream();
_book.Save(ms);

// clear book
_book.Clear();

// load it back from the MemoryStream
ms.Position = 0;
_book.Load(ms);</code></pre>



<a id="C1_WPF_Excel_C1XLBook_Save_" data-uid="C1.WPF.Excel.C1XLBook.Save*"></a>
<h4 id="C1_WPF_Excel_C1XLBook_Save_System_IO_Stream_C1_WPF_Excel_FileFormat_" data-uid="C1.WPF.Excel.C1XLBook.Save(System.IO.Stream,C1.WPF.Excel.FileFormat)">Save(Stream, FileFormat)</h4>
<div class="markdown level1 summary"><p>Saves the worksheet into a stream.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void Save(Stream stream, FileFormat format)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub Save(stream As Stream, format As FileFormat)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.stream">Stream</a></td>
      <td><span class="parametername">stream</span></td>
      <td><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.stream">Stream</a> where the worksheet is saved.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.WPF.Excel.FileFormat.html">FileFormat</a></td>
      <td><span class="parametername">format</span></td>
      <td><p><span class="xref">C1.WPF.Excel.C1XLBook.FileFormat</span> value that specifies the format to save the worksheet in.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
