Skip to content

Latest commit

 

History

History
74 lines (57 loc) · 2.79 KB

File metadata and controls

74 lines (57 loc) · 2.79 KB
title Loading and saving workbook in UWP | Syncfusion
description Explains how to load and save Excel files in UWP applications using Syncfusion XlsIO.
platform document-processing
control XlsIO
documentation UG

Loading and saving workbook in UWP

Opening an existing workbook

You can open an existing workbook by using the overloads of Open methods of IWorkbooks interface.

{% tabs %}
{% highlight c# tabtitle="C# [Windows-specific]" %} //Creates a new instance for ExcelEngine ExcelEngine excelEngine = new ExcelEngine();

//Initialize IApplication IApplication application = excelEngine.Excel;

//Instantiates the File Picker FileOpenPicker openPicker = new FileOpenPicker(); openPicker.SuggestedStartLocation = PickerLocationId.Desktop; openPicker.FileTypeFilter.Add(".xlsx"); openPicker.FileTypeFilter.Add(".xls"); StorageFile file = await openPicker.PickSingleFileAsync();

//Opens the workbook IWorkbook workbook = await application.Workbooks.OpenAsync(file, ExcelOpenType.Automatic); {% endhighlight %} {% endtabs %}

Saving an Excel workbook

You can also save the created or manipulated workbook using overloads of SaveAs methods.

{% tabs %} {% highlight c# tabtitle="C# [Windows-specific]" %} //Creates a new instance for ExcelEngine ExcelEngine excelEngine = new ExcelEngine();

//Initialize IApplication IApplication application = excelEngine.Excel;

//Instantiates the File Picker FileOpenPicker openPicker = new FileOpenPicker(); openPicker.SuggestedStartLocation = PickerLocationId.Desktop; openPicker.FileTypeFilter.Add(".xlsx"); openPicker.FileTypeFilter.Add(".xls"); StorageFile file = await openPicker.PickSingleFileAsync();

//Opens the workbook IWorkbook workbook = await application.Workbooks.OpenAsync(file, ExcelOpenType.Automatic);

//To-Do some manipulation //To-Do some manipulation

//Set the version of the workbook workbook.Version = ExcelVersion.Xlsx;

//Initializes FileSavePicker FileSavePicker savePicker = new FileSavePicker(); savePicker.SuggestedStartLocation = PickerLocationId.Desktop; savePicker.SuggestedFileName = "Output"; savePicker.FileTypeChoices.Add("Excel Files", new List() { ".xlsx" });

//Creates a storage file from FileSavePicker StorageFile storageFile = await savePicker.PickSaveFileAsync();

//Saves changes to the specified storage file await workbook.SaveAsAsync(storageFile); {% endhighlight %} {% endtabs %}