Reading Excel and Creating the Records in CRM


Install the following Packages

excelReader_1

excelReader_2

Reference the DLLs

excelReader_3

Use the following Code:

var filePath = @”D:\CRM\records.xlsx”;

                using (var stream = File.Open(filePath, FileMode.Open, FileAccess.Read))

                {

                    // Auto-detect format, supports:

                    using (var reader = ExcelReaderFactory.CreateReader(stream))

                    {

                        do

                        {

                            while (reader.Read())

                            {

                                //0 row is Header

                                if (reader.Depth != 0)

                                {

                                    var recordId = reader[2];

                                    var teamName = reader[3];

                                }

                            }

                        } while (reader.NextResult());

                    }

                }

Reference: https://github.com/ExcelDataReader/ExcelDataReader

Thanks:

KD

Advertisements

About Kishore Dhanekula

MS Dynamics CRM and .NET Architect
This entry was posted in CRM, Dynamics 365, MS Dynamics 365, MS Dynamics CRM 2015, MS Dynamics CRM 2016 and tagged , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s