Xamarin.Forms | ComponentOne
Controls / FlexGrid / Features / Export
In This Topic
    Export
    In This Topic

    FlexGrid allows you to export a file and save it to a device or a stream. You export files to text, CSV and HTML formats and save them to a file system, a Stream or a StreamWriter using Save method of the FlexGrid class. The Save method can save the exported file with different options of encoding and presentation of the FlexGrid data. The method has following seven overloads:

    Overload Description
    Save(StreamWriter, GridFileFormat, GridSaveOptions) Saves the contents of the grid to a System.IO.StreamWriter.
    Save(Stream, GridFileFormat, Encoding, GridSaveOptions) Saves the contents of the grid to a stream with specified memory location, format, encoding, and options.
    Save(Stream, GridFormat, GridSaveOptions) Saves the contents of the grid to a UTF8 encoded stream with specified memory location, format and options.
    Save(Stream, GridFileFormat) Saves the contents of the grid to a UTF8 encoded stream with specified memory location and format.
    Save(String, GridFileFormat, Encoding, GridSaveOptions) Saves the contents of the grid to a file a with specified name, format, encoding, and options.
    Save(String, GridFileFormat, GridSaveOptions) Saves the contents of the grid to a UTF8 encoded file with specified name, format and options.
    Save(String, GridFileFormat) Saves the content of the grid to a UTF8 encoded file with specified name and format.

    The following code example demonstrates the implementation of the Save method to save the exported file. The example uses the sample created in the Quick Start section.

    C#
    Copy Code
    //Export FlexGrid
    string PathAndName = Path.Combine(
        Environment.GetFolderPath(
            Environment.SpecialFolder.LocalApplicationData),
        "ExportedGrid") + "." + "csv";
    
    grid.Save(PathAndName, GridFileFormat.Csv, 
        System.Text.Encoding.UTF8, GridSaveOptions.SaveColumnHeaders);