Spread Windows Forms 18
Spread Windows Forms 18 Product Documentation / Developer's Guide / File Operations / Opening Existing Files / Opening an XML Data File
In This Topic
    Opening an XML Data File
    In This Topic

    Spread allows you to load and open an XML data file in the workbook. You can do this by using the OpenXML method of the IWorkbooks interface which accepts string type filename/stream as its parameter and returns an IWorkbook object.

    Opening XML data file using filename

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

    C#
    Copy Code
    // Opening XML data file in workbook using string type filename
    fpSpread1.Attach(fpSpread1.AsWorkbook().WorkbookSet.Workbooks.OpenXML("D:\\DataFormat.xml"));
    
    Visual Basic
    Copy Code
    ' 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.

    C#
    Copy Code
    // 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));
    
    Visual Basic
    Copy Code
    ' 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