Esempio n. 1
0
        private void ReadSheet(IXLWorksheet worksheet, CremaDataSet dataSet)
        {
            var dataTable = dataSet.Tables.FirstOrDefault(item => item.Name == worksheet.Name);

            if (dataTable == null)
            {
                if (worksheet.Name.IndexOf('~') >= 0)
                {
                    dataTable = dataSet.Tables.FirstOrDefault(item => SpreadsheetUtility.Ellipsis(item.Name) == worksheet.Name);
                }
            }

            if (dataTable == null)
            {
                return;
            }

            var columns = this.ReadColumns(dataTable, worksheet.FirstRow());

            foreach (var item in worksheet.Rows().Skip(1))
            {
                if (item.Cells(true).Any() == false)
                {
                    continue;
                }
                this.ReadRow(dataTable, columns, item);
            }
        }
Esempio n. 2
0
        public void Read(CremaDataSet dataSet, IProgress progress)
        {
            var query = from sheet in this.workbook.Worksheets
                        join table in dataSet.Tables on sheet.Name equals SpreadsheetUtility.Ellipsis(table.Name)
                        orderby table.Name
                        select sheet;

            var items = query.ToArray();

            var step = new StepProgress(progress);

            step.Begin(items.Length);
            foreach (var item in query)
            {
                this.ReadSheet(item, dataSet);
                step.Next("read {0} : {1}", ConsoleProgress.GetProgressString(step.Step + 1, items.Length), item.Name);
            }
            step.Complete();
        }