Geeks With Blogs
Deeksha Sharma
FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read);
IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
excelReader.IsFirstRowAsColumnNames = true;
   int totalrows = excelReader.AsDataSet().Tables[0].Rows.Count;
 foreach (DataRow dataRow in excelReader.AsDataSet().Tables[0].Rows)
            {
                if (!String.IsNullOrEmpty(dataRow["/CLOSINGLOGS/FILE_NUMBER"].ToString()))
                {
                    recordRow = dataRow;
                }
            }
  Order order = new Order();
            try
            {
                order.OrderNumber = recordRow["/CLOSINGLOGS/FILE_NUMBER"].ToString();
                order.ListingAgentName = recordRow["/CLOSINGLOGS/Listing Agent"].ToString();
                order.SellingAgentName = recordRow["/CLOSINGLOGS/Selling Agent"].ToString();
                order.BuyerName = recordRow["/CLOSINGLOGS/BUYER1"].ToString();
                order.PropertyAddress1 = recordRow["/CLOSINGLOGS/PROPERTY_STREET"].ToString();
                order.PropertyCounty = recordRow["/CLOSINGLOGS/COUNTY"].ToString();
                order.LenderName = recordRow["/CLOSINGLOGS/LENDER"].ToString();
                order.SellerName = recordRow["/CLOSINGLOGS/SELLER1"].ToString();
                order.TransactionType = recordRow["/CLOSINGLOGS/REFI"].ToString();
         }

We have mapped the data to an order object after reading from the excel sheet.
Posted on Friday, June 20, 2014 5:20 AM | Back to top


Comments on this post: Reading data from Excel SpreadSheet

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Deeksha Sharma | Powered by: GeeksWithBlogs.net