Browse Source

- Move away from IronXL

master
Dan 4 years ago
parent
commit
ffee3bdbc3
  1. 29
      FABStarterDeckGen/FABCollectionReader.cs
  2. 1
      FABStarterDeckGen/FabStarterDeckGen.csproj

29
FABStarterDeckGen/FABCollectionReader.cs

@ -1,7 +1,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using IronXL; using IronXL;
using Microsoft.Office.Interop.Excel;
using OfficeOpenXml;
using static System.Text.RegularExpressions.Regex; using static System.Text.RegularExpressions.Regex;
namespace FabStarterDeckGen namespace FabStarterDeckGen
@ -23,12 +26,12 @@ namespace FabStarterDeckGen
public Dictionary<string, int> CollectionCounts = new Dictionary<string, int>(); public Dictionary<string, int> CollectionCounts = new Dictionary<string, int>();
public void LoadCollection(string pFilePath, ReferenceCardLoader pReferenceCard) public void LoadCollection(string pFilePath, ReferenceCardLoader pReferenceCard)
{ {
WorkBook workbook = WorkBook.Load(pFilePath); ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using var package = new ExcelPackage(new FileInfo(pFilePath));
foreach (var sheet in workbook.WorkSheets) foreach (var sheet in package.Workbook.Worksheets)
{ {
var current_row_index = STARTING_ROW_INDEX; 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 != "") while (current_card_name != "")
{ {
Console.WriteLine(current_card_name); Console.WriteLine(current_card_name);
@ -38,41 +41,41 @@ namespace FabStarterDeckGen
{ {
if (card.IsPitchless) if (card.IsPitchless)
{ {
if( !CollectionCounts.ContainsKey(card.CleanName) ) if (!CollectionCounts.ContainsKey(card.CleanName))
CollectionCounts.Add(card.CleanName, 0); 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 else
{ {
if (card.IsRed) if (card.IsRed)
{ {
if( !CollectionCounts.ContainsKey(card.CleanNameRed) ) if (!CollectionCounts.ContainsKey(card.CleanNameRed))
CollectionCounts.Add(card.CleanNameRed, 0); 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 (card.IsYellow)
{ {
if( !CollectionCounts.ContainsKey(card.CleanNameYellow) ) if (!CollectionCounts.ContainsKey(card.CleanNameYellow))
CollectionCounts.Add(card.CleanNameYellow, 0); 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 (card.IsBlue)
{ {
if( !CollectionCounts.ContainsKey(card.CleanNameBlue) ) if (!CollectionCounts.ContainsKey(card.CleanNameBlue))
CollectionCounts.Add(card.CleanNameBlue, 0); 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_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;
} }
} }
} }

1
FABStarterDeckGen/FabStarterDeckGen.csproj

@ -14,6 +14,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="CsvHelper" Version="27.2.1" /> <PackageReference Include="CsvHelper" Version="27.2.1" />
<PackageReference Include="IronXL.Excel" Version="2022.3.0" /> <PackageReference Include="IronXL.Excel" Version="2022.3.0" />
<PackageReference Include="EPPlus" Version="6.0.5" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup> </ItemGroup>

Loading…
Cancel
Save