Xceed Workbooks for .NET v3.0 Documentation
Xceed.Workbooks.NET Assembly / Xceed.Workbooks.NET Namespace / DataTableImportOptions Class
Members Example


In This Topic
    DataTableImportOptions Class
    In This Topic
    Specifies the properties of the import options used when importing data tables in a Worksheet through the Worksheet.ImportData method.
    Syntax
    'Declaration
     
    
    Public Class DataTableImportOptions 
       Inherits ImportOptions
    'Usage
     
    
    Dim instance As DataTableImportOptions
    public class DataTableImportOptions : ImportOptions 
    Remarks
    This class derives from ImportOptions; it is useful when importing a data table.
    Example
    var workbook = Workbook.Create("test.xlsx" );
    
    var worksheet = workbook.Worksheets[ 0 ];
    
    // Define a dataTable, the import options(show specific ColumnNames) and call the ImportData function.
    
      var dataTable = new DataTable( "Employees" );
      dataTable.Columns.Add( "Name", typeof( string ) );
      dataTable.Columns.Add( "Position", typeof( string ) );
      dataTable.Columns.Add( "Experience", typeof( double ) );
      dataTable.Columns.Add( "Salary", typeof( int ) );
      dataTable.Rows.Add( "Jenny Melchuck", "Project Manager", 11.5d, 77000 );
      dataTable.Rows.Add( "Cindy Gartner", "Medical Assistant", 1.3d, 56000 );
      dataTable.Rows.Add( "Carl Jones", "Web Designer", 4d, 66000 );
      dataTable.Rows.Add( "Anna Karlweiss", "Account Executive", 7.8d, 51000 );
      dataTable.Rows.Add( "Julia Robertson", "Marketing Coordinator", 17.6d, 65000 );
      var dataTableImportOptions = new DataTableImportOptions() { DestinationTopLeftAddress = "B5", ColumnNames = new string[] { "Name", "Experience", "Position" }, IsColumnNamesShown = true };
      worksheet.ImportData( dataTable, dataTableImportOptions );
    
    workbook.Save();
    Inheritance Hierarchy

    System.Object
       Xceed.Workbooks.NET.ImportOptions
          Xceed.Workbooks.NET.DataTableImportOptions

    Public Constructors
    Public Properties
     NameDescription
    Public PropertyGets or sets the names of the data table’s columns.  
    Public PropertyGets or sets the Id of the Column in which the first data item will be imported. (Inherited from Xceed.Workbooks.NET.ImportOptions)
    Public PropertyGets or sets the Id of the Row in which the first data item will be imported.   (Inherited from Xceed.Workbooks.NET.ImportOptions)
    Public PropertyGets or sets the address of the Cell in which the first data item will be imported. (Inherited from Xceed.Workbooks.NET.ImportOptions)
    Public PropertyGets or sets if the data table’s ColumnNames will be shown or not.  
    Public PropertyGets or sets if the imported linear data (like a List<string>, Array<int>, MyProduct[], ...) will be displayed vertically in the Worksheet. (Inherited from Xceed.Workbooks.NET.ImportOptions)
    Top
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also