[]
Saves the workbook to disk.
[Obsolete("Use Save(string, SaveOptionsBase) instead.")]
public void Save(string fileName, string password = null, SaveOptions saveOptions = null)
<Obsolete("Use Save(string, SaveOptionsBase) instead.")>
Public Sub Save(fileName As String, Optional password As String = Nothing, Optional saveOptions As SaveOptions = Nothing)
| Type | Name | Description |
|---|---|---|
| string | fileName | The excel file. |
| string | password | The password of the file. |
| SaveOptions | saveOptions | Options for saving. |
Saves the workbook to disk.
public void Save(string fileName)
Public Sub Save(fileName As String)
| Type | Name | Description |
|---|---|---|
| string | fileName | The path of the destination file. |
worksheet.Range["A1:B2"].Value = new object[,] {
{"Name", "Value"},
{"Test", 100}
};
workbook.Save(Path.Combine(Environment.CurrentDirectory, "SalesReport.xlsx"));
Saves the workbook to the specified stream.
[Obsolete("Use Save(Stream, SaveOptionsBase) instead.")]
public void Save(Stream fileStream, string password = null, SaveOptions saveOptions = null)
<Obsolete("Use Save(Stream, SaveOptionsBase) instead.")>
Public Sub Save(fileStream As Stream, Optional password As String = Nothing, Optional saveOptions As SaveOptions = Nothing)
| Type | Name | Description |
|---|---|---|
| Stream | fileStream | The stream to which the workbook is saved. |
| string | password | The password of the file. |
| SaveOptions | saveOptions | Options for saving |
Saves the workbook to the specified stream.
public void Save(Stream fileStream)
Public Sub Save(fileStream As Stream)
| Type | Name | Description |
|---|---|---|
| Stream | fileStream | The output stream to which the workbook is saved. Must not be null. |
worksheet.Range["A1:B2"].Value = new object[,] {
{ "Name", "Value" },
{ "Test", 100 }
};
using (MemoryStream outputStream = new MemoryStream())
{
workbook.Save(outputStream);
byte[] bytes = outputStream.ToArray();
}
Saves the workbook to a file in the specified file format.
public void Save(string fileName, SaveFileFormat fileFormat)
Public Sub Save(fileName As String, fileFormat As SaveFileFormat)
| Type | Name | Description |
|---|---|---|
| string | fileName | The path of the destination file. |
| SaveFileFormat | fileFormat | The file format used to save the workbook. |
worksheet.Range["A1:B2"].Value = new object[,] {
{"Name", "Value"},
{"Test", 100}
};
workbook.Save(Path.Combine(Environment.CurrentDirectory, "SalesReport.xlsx"), SaveFileFormat.Xlsx);
Saves the workbook to a stream in the specified file format.
public void Save(Stream fileStream, SaveFileFormat fileFormat)
Public Sub Save(fileStream As Stream, fileFormat As SaveFileFormat)
| Type | Name | Description |
|---|---|---|
| Stream | fileStream | The stream to which the workbook is saved. |
| SaveFileFormat | fileFormat | The file format used to save the workbook to the stream. |
worksheet.Range["A1:B2"].Value = new object[,] {
{"Name", "Value"},
{"Test", 100}
};
using (MemoryStream outputStream = new MemoryStream())
{
workbook.Save(outputStream, SaveFileFormat.Xlsx);
byte[] bytes = outputStream.ToArray();
}
Saves the workbook to a file with the specified save options.
public void Save(string fileName, SaveOptionsBase options)
Public Sub Save(fileName As String, options As SaveOptionsBase)
| Type | Name | Description |
|---|---|---|
| string | fileName | The path of the destination file. |
| SaveOptionsBase | options | The options of saving the file. Possible types: |
worksheet.Range["A1:B2"].Value = new object[,] {
{"Name", "Value"},
{"Test", 100}
};
PdfSaveOptions options = new PdfSaveOptions();
workbook.Save(Path.Combine(Environment.CurrentDirectory, "report.pdf"), options);
Saves workbook to stream with specified options.
public void Save(Stream fileStream, SaveOptionsBase options)
Public Sub Save(fileStream As Stream, options As SaveOptionsBase)
| Type | Name | Description |
|---|---|---|
| Stream | fileStream | The stream to which the workbook is saved. |
| SaveOptionsBase | options | The options of saving the file stream. Possible types: |
worksheet.Range["A1:B2"].Value = new object[,] {
{"Name", "Value"},
{"Test", 100}
};
XlsxSaveOptions options = new XlsxSaveOptions();
options.IncludeAutoMergedCells = true;
using (MemoryStream stream = new MemoryStream())
{
workbook.Save(stream, options);
byte[] bytes = stream.ToArray();
}