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); + } + } + } + } } } } diff --git a/BarcodeXlsx/Properties/launchSettings.json b/BarcodeXlsx/Properties/launchSettings.json new file mode 100644 index 0000000..44425a6 --- /dev/null +++ b/BarcodeXlsx/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "BarcodeXlsx": { + "commandName": "Project", + "commandLineArgs": "-source C:\\Users\\07121\\Desktop\\Book1.xlsx" + } + } +} \ No newline at end of file