ComponentOne FlexPivot for WinForms
In This Topic
    Export
    In This Topic

    FlexPivot provides various methods to save its content in the desired format such as XML, Excel, and PDF at runtime or through code. At runtime, you can use the Export and Print options on the FlexPivot Toolstrip to export the content as excel and pdf, respectively. For exploring these options, see Toolstrip.

    Now, lets explore how to export FlexPivot and its content to different formats using code.

    Export to PDF

    To export FlexPivot and its content as pdf, you can use the PrintDocument class. You can simply set the value of PrinterName property to "Microsoft Print to PDF and use Print method of the PrintDocument class as demonstrated in the following code.

    C#
    Copy Code
    //Saves content as PDF
    var printDocument = flexPivotPage1.Document;
    printDocument.PrinterSettings.PrinterName = "Microsoft Print to PDF";
    printDocument.Print();  
    

    Save as XML

    To serialize the contents into an XML document, you can simply call WriteXml method of the C1FlexPivotGrid class and parse path of the XML document as a parameter. The method serializes all grid contents into the XML document, including the data stored in the cells, row and column properties.

    To save the grid content as XML, use the following code. This code exports all the content to an XML file named ExportedData in the bin directory of the project folder.

    C#
    Copy Code
    //Saves content as XML
    flexPivotPage1.FlexPivotGrid.WriteXml("../../ExportedData.xml");