# Opening an XML Data File

Learn how to open a Spread-compatible XML data file and access data and formatting using Spread's powerful capabilities.

## Content

Spread allows you to load and open an XML data file in the workbook. You can do this by using the [OpenXML](/spreadnet/api/latest/online-win/GrapeCity.Spreadsheet/GrapeCity.Spreadsheet.IWorkbooks.OpenXML.html) method of the [IWorkbooks](/spreadnet/api/latest/online-win/GrapeCity.Spreadsheet/GrapeCity.Spreadsheet.IWorkbooks.html) interface which accepts string type filename/stream as its parameter and returns an [IWorkbook](/spreadnet/api/latest/online-win/GrapeCity.Spreadsheet/GrapeCity.Spreadsheet.IWorkbook.html) object.

## Opening XML data file using filename

The following code is used to open a data file using filename.

```csharp
// Opening XML data file in workbook using string type filename
fpSpread1.Attach(fpSpread1.AsWorkbook().WorkbookSet.Workbooks.OpenXML("D:\\DataFormat.xml"));
```

```vbnet
' Opening XML data file in workbook using string type filename
FpSpread1.Attach(FpSpread1.AsWorkbook().WorkbookSet.Workbooks.OpenXML("D:\DataFormat.xml"))
```

## Opening XML data file using stream

The following code is used to open a workbook using stream parameter.

```csharp
// Opening XML data file in workbook using stream
System.IO.FileStream stream = new System.IO.FileStream("D:\\DataFormat.xml", System.IO.FileMode.Open, System.IO.FileAccess.Read);
fpSpread1.Attach(fpSpread1.AsWorkbook().WorkbookSet.Workbooks.OpenXML(stream));
```

```vbnet
' Opening XML data file in workbook using stream
Dim stream As System.IO.FileStream = New System.IO.FileStream("D:\DataFormat.xml", System.IO.FileMode.Open, System.IO.FileAccess.Read)
FpSpread1.Attach(FpSpread1.AsWorkbook().WorkbookSet.Workbooks.OpenXML(stream))
```

## See Also

[Opening an Excel File](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-usefiles/spwin-openfiles/spwin-open-excelfile)
[Opening a Custom Text File](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-usefiles/spwin-openfiles/spwin-open-textfile)
[Opening a Spread COM File](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-usefiles/spwin-openfiles/spwin-open-spreadcom)