diff --git a/BarcodeXlsx/Program.cs b/BarcodeXlsx/Program.cs index 28e497e..def9cd8 100644 --- a/BarcodeXlsx/Program.cs +++ b/BarcodeXlsx/Program.cs @@ -1,4 +1,9 @@ using System; +using System.Text; +using System.Text.RegularExpressions; + +using ClosedXML; +using ClosedXML.Excel; namespace BarcodeXlsx { @@ -8,7 +13,28 @@ { DecodeArgumentParamaters param = new DecodeArgumentParamaters(args); - Console.WriteLine("Hello World!"); + XLWorkbook book = new XLWorkbook(param.sourceFileName); + foreach(var sheet in book.Worksheets) + { + foreach (var cell in sheet.Cells()) + { + string cellValue = cell.GetString(); + if (cellValue.Length > param.preChars.Length + param.postChars.Length) + { + string preChars = cellValue.Substring(0, param.preChars.Length); + string postChears = cellValue.Substring(cellValue.Length - param.postChars.Length); + + if (preChars == param.preChars && postChears == param.postChars) + { + string barcodeData = cellValue.Substring(param.preChars.Length, cellValue.Length - param.preChars.Length - param.postChars.Length); + int delimiterPos = barcodeData.IndexOf(":"); + string barcodeType = barcodeData.Substring(0, delimiterPos); + string barcodeValue = barcodeData.Substring(delimiterPos + 1); + Console.WriteLine("barcodeType = {0}, barcodeValue = {1}", barcodeType, barcodeValue); + } + } + } + } } } }