Contents
- Opening an existing workbook from stream
- Saving an Excel workbook to stream
Having trouble getting help?
Contact Support
Contact Support
Loading and saving workbook on Linux
8 Dec 20231 minute to read
Opening an existing workbook from stream
You can open an existing workbook from stream by using the overloads of Open methods of IWorkbooks interface.
//Creates a new instance for ExcelEngine
ExcelEngine excelEngine = new ExcelEngine();
//Initialize IApplication
IApplication application = excelEngine.Excel;
//A existing workbook is opened.
FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream);
Saving an Excel workbook to stream
You can also save the created or manipulated workbook to stream using overloads of SaveAs methods.
//Creates a new instance for ExcelEngine
ExcelEngine excelEngine = new ExcelEngine();
//Initialize IApplication
IApplication application = excelEngine.Excel;
//A existing workbook is opened.
FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream);
//To-Do some manipulation
//To-Do some manipulation
//Set the version of the workbook
workbook.Version = ExcelVersion.Xlsx;
//Initialize stream
FileStream outputStream = new FileStream("Output.xlsx", FileMode.Create);
//Save the workbook as stream
workbook.SaveAs(outputStream);