Xceed Workbooks for .NET v1.4 Documentation
UserObjectImportOptions Class
Members  Example 


Xceed.Workbooks.NET Assembly > Xceed.Workbooks.NET Namespace : UserObjectImportOptions Class
Specifies the properties of the import options for user objects when importing data in a Worksheet through the Worksheet.ImportData method.
Syntax
'Declaration

 

Public Class UserObjectImportOptions 

   Inherits ImportOptions
'Usage

 

Dim instance As UserObjectImportOptions
public class UserObjectImportOptions : ImportOptions 
Remarks
This class derives from ImportOptions. It is useful when importing user object data, like a List<MyProduct>, a Player[] or an Array<Employee>.
Example
var workbook = Workbook.Create("test.xlsx" );



var worksheet = workbook.Worksheets[ 0 ];



// Define a list of user objects, the import options (vertical by default, specify PropertyNames and show propertyNames) and call the ImportData function.



  var userObjectData = new List<Player>()

  {

    new Player() { Name = "Tom Sawyer", Team = Team.Miami_Ducks, Number = 9 },

    new Player() { Name = "Mike Smith", Team = Team.Chicago_Hornets, Number = 18 },

    new Player() { Name = "Kelly Tomson", Team = Team.LosAngelese_Raiders, Number = 33 },

    new Player() { Name = "John Graham", Team = Team.NewYork_Bucs, Number = 7 },

  };



  var userObjectImportOptions = new UserObjectImportOptions() { DestinationTopLeftAddress = "H5", PropertyNames = new string[] { "Name", "Team" }, IsPropertyNamesShown = true };

  worksheet.ImportData( userObjectData, userObjectImportOptions );



workbook.Save();



private class Player

  {

    public string Name { get; set; }



    public int Number { get; set; }



    public Team Team { get; set; }

  }
Inheritance Hierarchy

System.Object
   Xceed.Workbooks.NET.ImportOptions
      Xceed.Workbooks.NET.UserObjectImportOptions

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

Reference

UserObjectImportOptions Members
Xceed.Workbooks.NET Namespace