Exemplo n.º 1
0
        public void SpreadsheetReadFile()
        {
            var excelMapper = new ExcelMapper();

            excelMapper.Add("A", "HotelKey", ExcelMapper.Type.String);
            excelMapper.Add("B", "HotelName", ExcelMapper.Type.String);
            excelMapper.Add("C", null, ExcelMapper.Type.String);
            excelMapper.Add("D", "LocationType", ExcelMapper.Type.String);
            excelMapper.Add("E", "Address_1", ExcelMapper.Type.String);
            excelMapper.Add("F", "Address_2", ExcelMapper.Type.String);
            excelMapper.Add("G", "Address_3", ExcelMapper.Type.String);
            excelMapper.Add("H", "Address_4", ExcelMapper.Type.String);
            excelMapper.Add("I", "Phone", ExcelMapper.Type.String);
            excelMapper.Add("J", "Fax", ExcelMapper.Type.String);
            excelMapper.Add("K", "Email", ExcelMapper.Type.String);
            excelMapper.Add("L", "Website", ExcelMapper.Type.String);
            excelMapper.Add("M", "StarRating", ExcelMapper.Type.Int);
            excelMapper.Add("N", "Category", ExcelMapper.Type.String);
            excelMapper.Add("O", "Latitude", ExcelMapper.Type.Double);
            excelMapper.Add("P", "Longitude", ExcelMapper.Type.Double);
            excelMapper.Add("Q", "CityCode", ExcelMapper.Type.String);
            excelMapper.Add("R", "CityName", ExcelMapper.Type.String);
            excelMapper.Add("S", "CountryCode", ExcelMapper.Type.String);
            excelMapper.Add("T", null, ExcelMapper.Type.String);
            excelMapper.Add("U", "CountryName", ExcelMapper.Type.String);

            JsonConvert.SerializeObject(excelMapper);

            var fileName      = @"E:\Source\Netbiis-Git\dotnet-spreadsheet\src\Netbiis.Spreadsheet\Netbiis.SpreadsheetTest\Files\HotelProvider.xlsx";
            var fileStream    = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            var spreadsheet   = new Excel();
            var hotelProvider = spreadsheet.ReadFile <HotelProvider>(fileStream, excelMapper, true);
        }