ASP.NET

In order to use XlsIO in your ASP.NET application, please add the required assemblies in your ASP.NET application. Refer Assemblies Required.

Saving the document

The following code snippet illustrates how to download an Excel document in browser after saving the document.

ExcelEngine excelEngine = new ExcelEngine();

IApplication application = excelEngine.Excel;

IWorkbook workbook = application.Workbooks.Create(1);

workbook.Version = ExcelVersion.Excel2010;

workbook.SaveAs("Output.xlsx", ExcelSaveType.SaveAsXLS, Response, ExcelDownloadType.PromptDialog);

workbook.Close();

excelEngine.Dispose();
Dim excelEngine As ExcelEngine = New ExcelEngine()

Dim application As IApplication = excelEngine.Excel

Dim workbook As IWorkbook = application.Workbooks.Create(1)

workbook.Version = ExcelVersion.Excel2010

workbook.SaveAs("Output.xlsx", ExcelSaveType.SaveAsXLS, Response, ExcelDownloadType.PromptDialog)

workbook.Close()

excelEngine.Dispose()

The following code snippet illustrates how to open the excel document in web browser after saving the document.

ExcelEngine excelEngine = new ExcelEngine();

IApplication application = excelEngine.Excel;

IWorkbook workbook = application.Workbooks.Create(1);

workbook.Version = ExcelVersion.Excel2010;

workbook.SaveAs("Output.xlsx", ExcelSaveType.SaveAsXLS, Response, ExcelDownloadType.Open);

workbook.Close();

excelEngine.Dispose();
Dim excelEngine As ExcelEngine = New ExcelEngine()

Dim application As IApplication = excelEngine.Excel

Dim workbook As IWorkbook = application.Workbooks.Create(1)

workbook.Version = ExcelVersion.Excel2010

workbook.SaveAs("Output.xlsx", ExcelSaveType.SaveAsXLS, Response, ExcelDownloadType.Open)

workbook.Close()

excelEngine.Dispose()

NOTE

The code after the SaveAs method won’t execute in Web platforms. To overcome this please refer the following KB How to execute next line of codes after invoking Workbook.SaveAs() method in XlsIO web application.