Exemple #1
0
        Transaction GetTransaction(int rowNumber)
        {
            IExcelSheet    sheet = _app.GetActiveWorkbook().GetActiveSheet();
            ExcelSheetData data  = sheet.GetSheetData(1, rowNumber);


            if (data.Rows.Count < 2)
            {
                return(null);
            }


            ExcelRowData headerRowData = data.Rows[0];

            ExcelRowData valueRowData = data.Rows[1];

            string separator = ";";
            string header    = headerRowData.GetValuesInLine(separator);
            string values    = valueRowData.GetValuesInLine(separator);

            TransactionParser parser      = new TransactionParser(header, separator.FirstOrDefault());
            Transaction       transaction = parser.ParseFromLine(values);

            return(transaction);
        }
Exemple #2
0
        public bool TryGetMonthReports(FileData data, out TransactionReport report)
        {
            report = null;

            try
            {
                string header = data.Lines.FirstOrDefault();
                if (header.IsNull())
                {
                    return(false);
                }

                report = new TransactionReport()
                {
                    Name = data.Name, Transactions = new List <Transaction>()
                };

                char separator           = Convert.ToChar(data.Separator);
                TransactionParser parser = new TransactionParser(header, separator);

                for (int i = 1; i < data.Lines.Count; i++)
                {
                    string      line         = data.Lines[i];
                    Transaction iTransaction = parser.ParseFromLine(line);
                    report.Transactions.Add(iTransaction);
                }
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }