|
| 1 | +--- |
| 2 | +title: How to get file extension of an Excel file | XlsIO | Syncfusion |
| 3 | +description: This page explains how to get the file extension of an Excel file using the Syncfusion .NET Excel library (XlsIO). |
| 4 | +platform: document-processing |
| 5 | +control: XlsIO |
| 6 | +documentation: UG |
| 7 | +--- |
| 8 | + |
| 9 | +# How to get the file extension of an Excel file using XlsIO? |
| 10 | + |
| 11 | +When an Excel file is opened with XlsIO, you can obtain its full path and extension from the [WorkbookImpl.FullFileName](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.Implementation.WorkbookImpl.html#Syncfusion_XlsIO_Implementation_WorkbookImpl_FullFileName) property. The following code snippet illustrates this. |
| 12 | + |
| 13 | +{% tabs %} |
| 14 | +{% highlight c# tabtitle="C# [Cross-platform]" %} |
| 15 | +using (ExcelEngine excelEngine = new ExcelEngine()) |
| 16 | +{ |
| 17 | + IApplication application = excelEngine.Excel; |
| 18 | + IWorkbook workbook = application.Workbooks.Open("Sample.xlsx"); |
| 19 | + |
| 20 | + string fileName = (workbook as WorkbookImpl).FullFileName; |
| 21 | + |
| 22 | + // Display file extension of excel file |
| 23 | + Console.WriteLine(Path.GetExtension(fileName)); |
| 24 | +} |
| 25 | +{% endhighlight %} |
| 26 | + |
| 27 | +{% highlight c# tabtitle="C# [Windows-specific]" %} |
| 28 | +using (ExcelEngine excelEngine = new ExcelEngine()) |
| 29 | +{ |
| 30 | + IApplication application = excelEngine.Excel; |
| 31 | + IWorkbook workbook = application.Workbooks.Open("Sample.xlsx"); |
| 32 | + |
| 33 | + string fileName = (workbook as WorkbookImpl).FullFileName; |
| 34 | + |
| 35 | + // Display file extension of excel file |
| 36 | + Console.WriteLine(Path.GetExtension(fileName)); |
| 37 | +} |
| 38 | +{% endhighlight %} |
| 39 | + |
| 40 | +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} |
| 41 | +Using excelEngine As New ExcelEngine() |
| 42 | + Dim application As IApplication = excelEngine.Excel |
| 43 | + Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx") |
| 44 | + |
| 45 | + Dim fileName As String = CType(workbook, WorkbookImpl).FullFileName |
| 46 | + |
| 47 | + ' Display file extension of excel file |
| 48 | + Console.WriteLine(Path.GetExtension(fileName)) |
| 49 | +End Using |
| 50 | +{% endhighlight %} |
| 51 | +{% endtabs %} |
| 52 | + |
0 commit comments