ComponentOne List for WinForms
Export, Import, and Print / Export
In This Topic
    Export
    In This Topic

    List provides various methods to save the list and its content in the desired format such as text, and excel formats.

    This topic discusses how to export list and its content to various formats.

    Save as Excel File

    To save list as an excel file, you can use ExportToExcel method of the C1List class and simply specify the file name. This method converts most data types and formatting information, including row and column dimensions, fonts, colors, formats, and cell alignment.

    To save the List as an Excel (.xls) file, use the following code.

    C#
    Copy Code
    //export to excel
    c1List1.ExportToExcel("c1list.xls");
    

    Save as Text File

    To save grid content as a text file, you can use ExportToDelimitedFile method of the C1List class. This method has various overloads which enable you to choose file location, delimeter and also lets you specify the rows to be saved.

    Overload Description
    ExportToDelimitedFile(string outPath, C1.Win.List.RowSelectorEnum selector) Exports the specified rows from the list to the specified file as delimited ASCII text by specifying.
    ExportToDelimitedFile(string outPath, C1.Win.List.RowSelectorEnum selector, string delim) Exports the specified rows from the list to the specified file as the specified delimited ASCII text.
    ExportToDelimitedFile(string outPath, C1.Win.List.RowSelectorEnum selector, string delim, string prefix) Exports the specified rows from the list to the specified file as delimited ASCII text preceded by an optional prefix.
    ExportToDelimitedFile(string outPath, C1.Win.List.RowSelectorEnum selector, string delim, string prefix, string suffix) Exports the specified rows from the list to the specified file as delimited ASCII text succeeded by an optional suffix.
    ExportToDelimitedFile(string outPath, C1.Win.List.RowSelectorEnum selector, string delim, string prefix, string suffix, bool headers) Exports the specified rows from the list to the specified file as delimited ASCII text with an optional prefix and suffix.

    The following table describes the options provided by the RowSelectorEnum enumeration.

    Options Description
    AllRows Exports all rows.
    CurrentRow Exports the current row
    SelectedRows Exports the selected rows.

    To save the list content as a text file, use the following code. This code exports all the rows and saves the list in a text file named c1list.

    C#
    Copy Code
    //export to text file
    c1List1.ExportToDelimitedFile("c1list.txt", C1.Win.List.RowSelectorEnum.AllRows, ",");
    

    Save Layout

    List lets you save the list layout in the xml format. You can use SaveLayout method of the C1List class to store the list layout as shown in the following code.

    C#
    Copy Code
    //save list layout
    c1List1.SaveLayout("c1list.xml",true);