diff --git a/FABStarterDeckGen/FABCollectionReader.cs b/FABStarterDeckGen/FABCollectionReader.cs index 7fb72d8..7a40022 100644 --- a/FABStarterDeckGen/FABCollectionReader.cs +++ b/FABStarterDeckGen/FABCollectionReader.cs @@ -1,7 +1,10 @@ using System; using System.Collections.Generic; +using System.IO; using System.Text.RegularExpressions; using IronXL; +using Microsoft.Office.Interop.Excel; +using OfficeOpenXml; using static System.Text.RegularExpressions.Regex; namespace FabStarterDeckGen @@ -22,13 +25,13 @@ namespace FabStarterDeckGen public Dictionary CollectionCounts = new Dictionary(); public void LoadCollection(string pFilePath, ReferenceCardLoader pReferenceCard) - { - WorkBook workbook = WorkBook.Load(pFilePath); - - foreach (var sheet in workbook.WorkSheets) + { + ExcelPackage.LicenseContext = LicenseContext.NonCommercial; + using var package = new ExcelPackage(new FileInfo(pFilePath)); + foreach (var sheet in package.Workbook.Worksheets) { var current_row_index = STARTING_ROW_INDEX; - var current_card_name = sheet[COLUMN_NAME + current_row_index.ToString()].StringValue; + var current_card_name = sheet.Cells[COLUMN_NAME + current_row_index.ToString()].Text; while (current_card_name != "") { Console.WriteLine(current_card_name); @@ -38,41 +41,41 @@ namespace FabStarterDeckGen { if (card.IsPitchless) { - if( !CollectionCounts.ContainsKey(card.CleanName) ) + if (!CollectionCounts.ContainsKey(card.CleanName)) CollectionCounts.Add(card.CleanName, 0); - - CollectionCounts[card.CleanName] += sheet[COLUMN_RED + current_row_index.ToString()].IntValue; + + CollectionCounts[card.CleanName] += int.Parse(sheet.Cells[COLUMN_RED + current_row_index.ToString()].Text); } else { if (card.IsRed) { - if( !CollectionCounts.ContainsKey(card.CleanNameRed) ) + if (!CollectionCounts.ContainsKey(card.CleanNameRed)) CollectionCounts.Add(card.CleanNameRed, 0); - - CollectionCounts[card.CleanNameRed] += sheet[COLUMN_RED + current_row_index.ToString()].IntValue; + + CollectionCounts[card.CleanNameRed] += int.Parse(sheet.Cells[COLUMN_RED + current_row_index.ToString()].Text); } if (card.IsYellow) { - if( !CollectionCounts.ContainsKey(card.CleanNameYellow) ) + if (!CollectionCounts.ContainsKey(card.CleanNameYellow)) CollectionCounts.Add(card.CleanNameYellow, 0); - - CollectionCounts[card.CleanNameYellow] += sheet[COLUMN_YELLOW + current_row_index.ToString()].IntValue; + + CollectionCounts[card.CleanNameYellow] += int.Parse(sheet.Cells[COLUMN_YELLOW + current_row_index.ToString()].Text); } - + if (card.IsBlue) { - if( !CollectionCounts.ContainsKey(card.CleanNameBlue) ) + if (!CollectionCounts.ContainsKey(card.CleanNameBlue)) CollectionCounts.Add(card.CleanNameBlue, 0); - - CollectionCounts[card.CleanNameBlue] += sheet[COLUMN_BLUE + current_row_index.ToString()].IntValue; + + CollectionCounts[card.CleanNameBlue] += int.Parse(sheet.Cells[COLUMN_BLUE + current_row_index.ToString()].Text); } } } - + current_row_index++; - current_card_name = sheet[COLUMN_NAME + current_row_index.ToString()].StringValue; + current_card_name = sheet.Cells[COLUMN_NAME + current_row_index.ToString()].Text; } } } diff --git a/FABStarterDeckGen/FabStarterDeckGen.csproj b/FABStarterDeckGen/FabStarterDeckGen.csproj index c09b4fc..76f4b86 100644 --- a/FABStarterDeckGen/FabStarterDeckGen.csproj +++ b/FABStarterDeckGen/FabStarterDeckGen.csproj @@ -14,6 +14,7 @@ +