| title | How to save a file to stream | XlsIO | Syncfusion |
|---|---|
| description | This page demonstrates with an example to save a file to stream using Syncfusion .NET Excel library (XlsIO). |
| platform | document-processing |
| control | XlsIO |
| documentation | UG |
XlsIO provides support to save a workbook to a .NET stream. The following code snippet illustrates this.
{% tabs %}
{% highlight c# tabtitle="C# [Cross-platform]" %}
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic);
//Save the workbook to stream FileStream fileStream = new FileStream("Output.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite); workbook.SaveAs(fileStream); workbook.Close(); excelEngine.Dispose(); } {% endhighlight %}
{% highlight c# tabtitle="C# [Windows-specific]" %} using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2013; IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic);
//Save the workbook to stream FileStream fileStream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); workbook.SaveAs(fileStream); } {% endhighlight %}
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Using excelEngine As ExcelEngine = New ExcelEngine() Dim application As IApplication = excelEngine.Excel application.DefaultVersion = ExcelVersion.Excel2013 Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic)
'Save the workbook to stream Dim fileStream As New FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite) workbook.SaveAs(fileStream) End Using {% endhighlight %} {% endtabs %}
- How to open an Excel file from stream? How to save an Excel workbook to stream?
- How to resolve the File does not contain workbook stream error in Syncfusion.XlsIO.Base.dll?
- How to resolve Excel cannot open the file filename.xlsx... error?
- How to open an existing XLSX workbook and save it as XLS?
- How to merge excel files from more than one workbook to a single file?
- Does XlsIO support Excel files with macros that are digitally signed?
- How does Excel file with uninstalled fonts is converted to PDF/Image?