/// <summary>
        /// Asserts whether the switch cell of the <paramref name="excelRow"/> needs to be locked or not
        /// </summary>
        /// <param name="excelRow">
        /// The <see cref="IExcelRow{T}"/> for which the locking needs to be determined
        /// </param>
        /// <returns>
        /// returns true if the cell needs to be locked, false if it should not be locked
        /// </returns>
        private bool IsSwitchCellLocked(IExcelRow <Thing> excelRow)
        {
            switch (excelRow.Type)
            {
            case ParameterSheetConstants.POVSCD:
                return(false);

            case ParameterSheetConstants.PSVSCD:
                return(false);

            case ParameterSheetConstants.PVSCD:
                return(false);

            case ParameterSheetConstants.POVS:
                return(false);

            case ParameterSheetConstants.PSVS:
                return(false);

            case ParameterSheetConstants.PVS:
                return(false);

            default:
                return(true);
            }
        }
예제 #2
0
        public bool SetRowInfo(short sheet, int row, int columnFirstDef, int columnLastDefPlus1, short ixf, double height, byte outlineLevel, bool collapsed, bool hidden, bool unSynced, bool ghostDirty)
        {
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];

            if (worksheet.RowCount <= row)
            {
                worksheet.RowCount = row;
            }
            IExcelRow row2 = worksheet.GetRow(row, true);

            if (row2 == null)
            {
                return(false);
            }
            if (ghostDirty)
            {
                row2.SetFormatId(ixf);
            }
            row2.Collapsed    = collapsed;
            row2.OutLineLevel = outlineLevel;
            if (!double.IsNaN(height))
            {
                row2.Height = height;
            }
            row2.Visible = !hidden;
            return(true);
        }
예제 #3
0
        private void ShowLineDifference(int rowIndex)
        {
            rowDiffGrid.DataSource = null;

            IExcelRow leftRow     = currentSheet.left.GetRow(rowIndex);
            IExcelRow rightRow    = currentSheet.right.GetRow(rowIndex);
            int       columnCount = currentSheet.columnCount;

            lineTable.Rows.Clear();
            DataRow row = lineTable.NewRow();

            for (int i = 0; i < columnCount; i++)
            {
                row[i] = SafeGetColumn(leftRow, i);
            }
            lineTable.Rows.Add(row);

            row = lineTable.NewRow();
            for (int i = 0; i < columnCount; i++)
            {
                row[i] = SafeGetColumn(rightRow, i);
            }
            lineTable.Rows.Add(row);

            rowDiffGrid.DataSource = lineTable;
        }
예제 #4
0
파일: ExcelWriter.cs 프로젝트: Daoting/dt
        public bool GetCells(short sheet, List <IExcelCell> cells)
        {
            if (cells == null)
            {
                throw new ArgumentNullException("cells");
            }
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];

            if (worksheet == null)
            {
                return(false);
            }
            List <IExcelRow> nonEmptyRows = worksheet.GetNonEmptyRows();

            for (int i = 0; i < nonEmptyRows.Count; i++)
            {
                IExcelRow         row           = nonEmptyRows[i];
                List <IExcelCell> nonEmptyCells = worksheet.GetNonEmptyCells(row.Index);
                if (nonEmptyCells.Count > 0)
                {
                    cells.AddRange((IEnumerable <IExcelCell>)nonEmptyCells);
                }
            }
            return(true);
        }
예제 #5
0
        /// <summary>
        /// 根据实际的行号获取行对象
        /// </summary>
        /// <param name="realRowIndex"></param>
        /// <returns></returns>
        public IExcelRow GetRowByRealIndex(int realRowIndex)
        {
            IExcelRow row = null;

            _realRowMap.TryGetValue(realRowIndex, out row);
            return(row);
        }
예제 #6
0
        public RowRecord Add(IExcelRow row, ISheet sheet, IExcelRowParseResult parseResult)
        {
            if (row == null)
            {
                throw new ArgumentNullException(nameof(row));
            }
            if (sheet == null)
            {
                throw new ArgumentNullException(nameof(sheet));
            }

            var excelFileRecord = sheet.Parent as ExcelFileRecord;

            if (excelFileRecord == null)
            {
                throw new ArgumentException("could not cast container as ExcelFileRecord");
            }
            var sheetRecord = sheet as SheetRecord;

            if (sheetRecord == null)
            {
                throw new ArgumentException("could not cast sheet as SheetRecord");
            }

            var rowRecord = new RowRecord(row, sheetRecord, parseResult);

            db.Add(rowRecord);
            return(rowRecord);
        }
예제 #7
0
        /// <summary>
        /// Apply the formula to the computed-column
        /// </summary>
        /// <param name="excelRow">
        /// The <see cref="IExcelRow{Thing}"/> that contains the formula that is to be applied
        /// </param>
        /// <param name="rownumber">
        /// The row in excel that needs the formula applied
        /// </param>
        private void ApplyFormulaValueToComputedValueCell(IExcelRow <Thing> excelRow, int rownumber)
        {
            if (excelRow is ElementDefinitionExcelRow || excelRow is ElementUsageExcelRow || excelRow is ParameterGroupExcelRow)
            {
                return;
            }

            var parameterRow = excelRow as ParameterExcelRow;

            if (parameterRow != null && parameterRow.Thing.ParameterType is CompoundParameterType)
            {
                return;
            }

            var parameterValueSetRow = excelRow as ParameterValueSetExcelRow;

            if (parameterValueSetRow != null)
            {
                var parameter = (CDP4Common.EngineeringModelData.Parameter)parameterValueSetRow.Thing.Container;
                if (parameter.ParameterType is CompoundParameterType)
                {
                    return;
                }
            }

            var subscriptionValueSetRow = excelRow as ParameterSubscriptionExcelRow;

            if (subscriptionValueSetRow != null)
            {
                return;
            }

            var parameterSubscriptionValueSetExcelRow = excelRow as ParameterSubscriptionValuesetExcelRow;

            if (parameterSubscriptionValueSetExcelRow != null)
            {
                return;
            }

            var componentExcelRow = excelRow as ComponentExcelRow;

            if (componentExcelRow != null)
            {
                if (componentExcelRow.Container is ParameterSubscriptionExcelRow || componentExcelRow.Container is ParameterSubscriptionValuesetExcelRow)
                {
                    return;
                }
            }

            try
            {
                this.parameterSheet.Cells[rownumber, ParameterSheetConstants.ComputedColumn].Formula = excelRow.Formula;
            }
            catch (Exception ex)
            {
                logger.Error(ex, "The formula {0} could not be written", excelRow.Formula);
            }
        }
 public ExcelRowParseOnTypeRequest RowParseOnTypeRequest(IExcelRow row) =>
 new ExcelRowParseOnTypeRequest
 {
     NamingStrategy = NamingStrategy,
     RootType       = this.OnType(),
     Options        = SheetsOptions?.FirstOrDefault(o => o.SheetIndex == row.Sheet.Index) ??
                      SheetMappingOptions.Default(row.Sheet.Index),
     Row = row
 };
예제 #9
0
        private int GetRealRowIndex(IExcelRow row)
        {
            int index = -1;

            if (row != null && row is VRow)
            {
                index = ((VRow)row).realRowIndex;
            }
            return(index);
        }
예제 #10
0
        /// <summary>
        /// 增加一个新的行
        /// </summary>
        /// <returns></returns>
        internal VRow NewRow(IExcelRow referenceRow)
        {
            VRow row = new VRow(this, _rows.Count, referenceRow);

            _rows.Add(row);
            if (row.realRowIndex != -1)
            {
                _realRowMap.Add(row.realRowIndex, row);
            }
            return(row);
        }
예제 #11
0
 /// <summary>
 /// 添加单元格
 /// </summary>
 /// <param name="row">单元行</param>
 /// <param name="cell">单元格</param>
 /// <param name="rowIndex">行索引</param>
 private void AddCell(IExcelRow row, IExcelCell cell, int rowIndex)
 {
     row.Add(cell);
     if (cell.RowSpan <= 1)
     {
         return;
     }
     for (int i = 1; i < cell.RowSpan; i++)
     {
         AddPlaceholderCell(cell, rowIndex + i);
     }
 }
예제 #12
0
        private string SafeGetColumn(IExcelRow row, int columnIndex)
        {
            if (row == null)
            {
                return(string.Empty);
            }
            IExcelCell cell = row.GetCell(columnIndex);

            if (cell != null && cell.value != null)
            {
                return(cell.value);
            }
            return(string.Empty);
        }
예제 #13
0
        public virtual IdParseResult ParseId(IExcelRow row, SheetMappingOptions options)
        {
            var result = new IdParseResult
            {
                InvalidForeignIdValue = false,
                InvalidIdValue        = false
            };
            var id = 0;

            var excludeColumns = new List <int>();



            if (options.IdIndex.HasValue)
            {
                excludeColumns.Add(options.IdIndex.Value);
                var val = row.Cells[options.IdIndex.Value].Value?.ToString();
                if (int.TryParse(val, out id))
                {
                    result.UserDefinedId = id;
                }
                else
                {
                    result.InvalidIdValue = true;
                }
            }

            if (options.IndexAsId)
            {
                result.UserDefinedId  = row.Index;
                result.InvalidIdValue = false;
            }

            if (options.ParentIdIndex.HasValue)
            {
                excludeColumns.Add(options.ParentIdIndex.Value);
                var val = row.Cells[options.ParentIdIndex.Value].Value?.ToString();
                if (int.TryParse(val, out id))
                {
                    result.ForeignUserDefinedId = id;
                }
                else
                {
                    result.InvalidForeignIdValue = true;
                }
            }

            result.ExcludeColumns = excludeColumns.ToArray();
            return(result);
        }
예제 #14
0
        /// <summary>
        /// Apply grouping to the excel rows to allow expanding and collapsing in excel
        /// </summary>
        /// <param name="excelRow">
        /// The <see cref="IExcelRow{Thing}"/> that contains the level information
        /// </param>
        /// <param name="rownumber">
        /// The row in excel that needs the grouping to be applied
        /// </param>
        private void ApplyRowGrouping(IExcelRow <Thing> excelRow, int rownumber)
        {
            var outlineLevel = excelRow.Level + 1;

            this.parameterSheet.Cells[rownumber, 14].Value = outlineLevel;

            if (outlineLevel < 8)
            {
                this.parameterSheet.Rows[rownumber].EntireRow.OutlineLevel = outlineLevel;
            }
            else
            {
                this.parameterSheet.Rows[rownumber].EntireRow.OutlineLevel = 8;
            }
        }
예제 #15
0
파일: ExcelWriter.cs 프로젝트: Daoting/dt
        public bool GetRowPageBreaks(short sheet, List <short> pageBreaks)
        {
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];
            ushort          num       = (ushort)Math.Min(0xffff, worksheet.RowCount);

            for (short i = 0; i < num; i++)
            {
                IExcelRow row = worksheet.GetRow(i, false);
                if ((row != null) && row.PageBreak)
                {
                    pageBreaks.Add(i);
                }
            }
            return(true);
        }
예제 #16
0
        public void CompareCells(int columnCount, IExcelSheet left, IExcelSheet right)
        {
            _isDifferent = false;
            _cellStatus  = new bool[columnCount];
            IExcelRow leftRow  = left.GetRow(_leftRowIndex);
            IExcelRow rightRow = right.GetRow(_rightRowIndex);

            if (leftRow == null || rightRow == null)
            {
                for (int i = 0; i < columnCount; i++)
                {
                    _cellStatus[i] = true;
                }
            }
            else
            {
                for (int columnIndex = 0; columnIndex < columnCount; columnIndex++)
                {
                    IExcelCell selfCell  = leftRow.GetCell(columnIndex);
                    IExcelCell otherCell = rightRow.GetCell(columnIndex);
                    if ((selfCell == null && otherCell != null) || (selfCell != null && otherCell == null))
                    {
                        _cellStatus[columnIndex] = true;
                    }
                    else
                    {
                        if (selfCell == null && otherCell == null)
                        {
                            _cellStatus[columnIndex] = false;
                        }
                        else
                        {
                            _cellStatus[columnIndex] = string.Compare(selfCell.GetContent(), otherCell.GetContent()) != 0;
                        }
                    }
                }
            }

            for (int i = 0; i < _cellStatus.Length; i++)
            {
                if (_cellStatus[i])
                {
                    _isDifferent = true;
                    break;
                }
            }
        }
예제 #17
0
        public VRow(VSheet sheet, int rowIndex, IExcelRow referenceRow)
        {
            _sheet    = sheet;
            _rowIndex = rowIndex;

            if (referenceRow != null)
            {
                if (referenceRow is VRow)
                {
                    VRow row = referenceRow as VRow;
                    _realRowIndex   = row.realRowIndex;
                    _targetRowIndex = row.targetRowIndex;
                }
                else
                {
                    ExcelRow row = referenceRow as ExcelRow;
                    _realRowIndex = rowIndex;
                }

                for (int columnIndex = 0; columnIndex < sheet.columnCount; columnIndex++)
                {
                    IExcelCell cell    = referenceRow.GetCell(columnIndex);
                    IExcelCell newCell = null;
                    if (cell == null)
                    {
                        newCell = new ExcelCell(_rowIndex, columnIndex);
                    }
                    else
                    {
                        newCell = new ExcelCell(_rowIndex, columnIndex, cell.cellType, cell.value);
                    }

                    _columns.Add(newCell);
                }
            }
            else
            {
                _realRowIndex = -1;
                for (int columnIndex = 0; columnIndex < sheet.columnCount; columnIndex++)
                {
                    _columns.Add(new ExcelCell(_rowIndex, columnIndex));
                }
            }
        }
예제 #18
0
        private void WriteCells(IEnumerable <PropertyInfo> properties, Row sheetRow, IExcelRow userRow)
        {
            var columnIndex = 0;

            foreach (var item in properties)
            {
                var cellValue = item.GetValue(userRow);

                sheetRow.InsertAt(
                    new Cell
                {
                    CellValue = new CellValue(cellValue == null ? string.Empty : cellValue.ToString()),
                    DataType  = new EnumValue <CellValues>(this.ResolveCellType(item.PropertyType))
                },
                    columnIndex);

                columnIndex++;
            }
        }
예제 #19
0
        /// <summary>
        /// Apply the formula to the actual value column
        /// </summary>
        /// <param name="excelRow">
        /// The <see cref="IExcelRow{Thing}"/> that contains the level information
        /// </param>
        /// <param name="rownumber">
        /// The row in excel that needs the formula applied
        /// </param>
        private void ApplyActualValueFormula(IExcelRow <Thing> excelRow, int rownumber)
        {
            if (excelRow is ElementDefinitionExcelRow || excelRow is ElementUsageExcelRow || excelRow is ParameterGroupExcelRow || excelRow is ParameterSubscriptionValuesetExcelRow)
            {
                return;
            }

            var parameterRow = excelRow as ParameterExcelRow;

            if (parameterRow != null && parameterRow.Thing.ParameterType is CompoundParameterType)
            {
                return;
            }

            var parameterValueSetRow = excelRow as ParameterValueSetExcelRow;

            if (parameterValueSetRow != null)
            {
                var parameter = (CDP4Common.EngineeringModelData.Parameter)parameterValueSetRow.Thing.Container;
                if (parameter.ParameterType is CompoundParameterType)
                {
                    return;
                }
            }

            var switchaddress    = string.Format("R{0}C{1}", rownumber, ParameterSheetConstants.SwitchColumn);
            var manualAddress    = string.Format("R{0}C{1}", rownumber, ParameterSheetConstants.ManualColumn);
            var computedAddress  = string.Format("R{0}C{1}", rownumber, ParameterSheetConstants.ComputedColumn);
            var referenceAddress = string.Format("R{0}C{1}", rownumber, ParameterSheetConstants.ReferenceColumn);

            var formula = string.Format("={0}({1}=\"MANUAL\"{5}{2}{5}{0}({1}=\"COMPUTED\"{5}{3}{5}{4}))", this.conditionalFunction, switchaddress, manualAddress, computedAddress, referenceAddress, this.listSeparator);

            try
            {
                this.parameterSheet.Cells[rownumber, ParameterSheetConstants.ActualValueColumn].FormulaR1C1Local = formula;
            }
            catch (Exception ex)
            {
                logger.Error(ex, "The formula {0} could not be written", formula);
            }
        }
예제 #20
0
        /// <summary>
        /// Gets the row at the specified column index
        /// </summary>
        /// <param name="index">The zero-based index of the row.</param>
        /// <param name="create">If set to <see langword="true" />. It will create the column if
        /// the row is null at the specified index when the index is in the valid range</param>
        /// <returns>
        /// An <see cref="T:Dt.Xls.IExcelRow" /> instance represent the column at the specified index
        /// </returns>
        public IExcelRow GetRow(int index, bool create = true)
        {
            IExcelRow row = this._rows1[index];

            if (row != null)
            {
                return(row);
            }
            if (((index >= 0) && (index < this._rowCount)) && create)
            {
                ExcelRow row2 = new ExcelRow(this)
                {
                    Index  = index,
                    Height = this._defaultRowHeight
                };
                row = row2;
                this._rows1[index] = row;
                return(row);
            }
            return(null);
        }
예제 #21
0
        public DataTable GetSource()
        {
            DataTable dt = new DataTable();

            for (int j = 0; j < _columnCount; j++)
            {
                dt.Columns.Add(new DataColumn(CellReference.ConvertNumToColString(j)));
            }

            DataRow dr = null;

            for (int i = 0; i < rowCount; i++)
            {
                dr = dt.NewRow();
                IExcelRow row = _rows[i];
                for (int k = 0; k < _columnCount; k++)
                {
                    if (k < columnCount && row != null)
                    {
                        string displayText = row.GetCell(k).value;
                        if (displayText == null)
                        {
                            displayText = string.Empty;
                        }
                        dr[k] = displayText;
                    }
                    else
                    {
                        dr[k] = string.Empty;
                    }
                }

                dt.Rows.Add(dr);
            }
            return(dt);
        }
예제 #22
0
        public void CopyFrom(IExcelRow other)
        {
            VRow row = other as VRow;

            _targetRowIndex = row.realRowIndex;
            _columns.Clear();
            _changed = true;

            for (int columnIndex = 0; columnIndex < sheet.columnCount; columnIndex++)
            {
                IExcelCell cell    = row.GetCell(columnIndex);
                IExcelCell newCell = null;
                if (cell == null)
                {
                    newCell = new ExcelCell(_rowIndex, columnIndex);
                }
                else
                {
                    newCell = new ExcelCell(_rowIndex, columnIndex, cell.cellType, cell.value);
                }

                _columns.Add(newCell);
            }
        }
예제 #23
0
        /// <summary>
        /// Apply row validation using the information from the <see cref="IExcelRow{Thing}"/> and
        /// </summary>
        /// <param name="excelRow">
        /// An instance of <see cref="IExcelRow{Thing}"/> that contains the information used to apply the proper validation
        /// </param>
        /// <param name="rownumber">
        /// The number of the row in the parameter sheet
        /// </param>
        private void ApplyRowValidation(IExcelRow <Thing> excelRow, int rownumber)
        {
            Validation validation;

            if (excelRow is ComponentExcelRow)
            {
                var componentnumber    = excelRow.Id.Split(':');
                var parameterRowNumber = (rownumber - 1) - int.Parse(componentnumber[1]);

                this.parameterSheet.Cells[rownumber, ParameterSheetConstants.SwitchColumn].FormulaR1C1 = string.Format("=R{0}C{1}", parameterRowNumber, ParameterSheetConstants.SwitchColumn);
            }
            else
            {
                // switch
                if (excelRow.Type != ParameterSheetConstants.ED && excelRow.Type != ParameterSheetConstants.PG)
                {
                    validation = this.parameterSheet.Cells[rownumber, ParameterSheetConstants.SwitchColumn].Validation;
                    ApplyValidation(validation, this.switchFormula);
                }
            }

            if (excelRow.ParameterType == null)
            {
                logger.Debug("The parametertype of excelrow at address {0} is not specified: ", rownumber);
            }

            var booleanParameterType = excelRow.ParameterType as BooleanParameterType;

            if (booleanParameterType != null)
            {
                var formula = string.Format("-{0}FALSE{0}TRUE", this.listSeparator);

                // manual value
                validation = this.parameterSheet.Cells[rownumber, ParameterSheetConstants.ManualColumn].Validation;
                ApplyValidation(validation, formula);

                // reference value
                validation = this.parameterSheet.Cells[rownumber, ParameterSheetConstants.ReferenceColumn].Validation;
                ApplyValidation(validation, formula);
            }

            var enumerationParameterType = excelRow.ParameterType as EnumerationParameterType;

            if (enumerationParameterType != null)
            {
                var formula = this.ValueDefinitionValidationFormula(enumerationParameterType);
                if (formula != string.Empty)
                {
                    // manual value
                    validation = this.parameterSheet.Cells[rownumber, ParameterSheetConstants.ManualColumn].Validation;
                    ApplyValidation(validation, formula);

                    // reference value
                    validation = this.parameterSheet.Cells[rownumber, ParameterSheetConstants.ReferenceColumn].Validation;
                    ApplyValidation(validation, formula);
                }
                else
                {
                    var range = this.parameterSheet.Cells[rownumber, ParameterSheetConstants.ManualColumn];
                    ApplyComment(range, "CDP4: /r/n/ No ManualValue Definitions have been defined /r/n Please update The Parameter Type", false);
                }
            }
        }
예제 #24
0
        /// <summary>
        /// Generate content row and names
        /// </summary>
        /// <param name="excelRow">
        /// Current <see cref="IExcelRow{T}"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.ValueTuple"/> that contains element specific data
        /// </returns>
        private (object[] content, object[] names) ContentRowSelector(IExcelRow <Thing> excelRow)
        {
            var contentRow = new object[this.numberOfColumns];
            var namesRow   = new object[this.numberOfColumns];

            contentRow[0] = excelRow.Name;
            contentRow[1] = excelRow.ShortName;
            contentRow[2] = excelRow.Type;
            contentRow[3] = excelRow.Owner;
            contentRow[4] = excelRow.Categories;

            List <ParameterOrOverrideBase> parameters;

            switch (excelRow.Thing)
            {
            case ElementUsage elementUsage:
                parameters = this.parameterTypes
                             .Select(pt => GetParameterOrOverrideBase(elementUsage, pt))
                             .Where(p => p != null)
                             .ToList();

                break;

            case ElementDefinition elementDefinition:
                parameters = this.parameterTypes
                             .Select(pt => GetParameterOrOverrideBase(elementDefinition, pt))
                             .Where(p => p != null)
                             .ToList();

                break;

            default:
                return(contentRow, namesRow);
            }

            foreach (var parameterOrOverrideBase in parameters)
            {
                foreach (var parameterValueSetBase in parameterOrOverrideBase.ValueSets.Cast <ParameterValueSetBase>())
                {
                    if (parameterOrOverrideBase.ParameterType is CompoundParameterType compoundParameterType)
                    {
                        for (var i = 0; i < compoundParameterType.NumberOfValues; ++i)
                        {
                            var component = compoundParameterType.Component[i];
                            var value     = parameterValueSetBase.ActualValue[i];

                            var index = this.GetContentColumnIndex(parameterValueSetBase, component);
                            contentRow[index] = value;
                            namesRow[index]   = GetCellName(excelRow.Thing, parameterValueSetBase, i);
                        }
                    }
                    else
                    {
                        var index = this.GetContentColumnIndex(parameterValueSetBase);
                        contentRow[index] = parameterValueSetBase.ActualValue.First();
                        namesRow[index]   = GetCellName(excelRow.Thing, parameterValueSetBase);
                    }
                }
            }

            CrossviewSheetPMeanUtilities.ComputePMean(this, contentRow, namesRow, parameters);

            return(contentRow, namesRow);
        }
예제 #25
0
        public void Execute(IExcelSheet left, IExcelSheet right, int leftAlignIndex = -1, int rightAlignIndex = -1)
        {
            _isDifferent = false;

            _columnCount = Math.Max(left.columnCount, right.columnCount);
            _left        = new VSheet(left, _columnCount);
            _right       = new VSheet(right, _columnCount);

            _leftAlignIndex  = leftAlignIndex;
            _rightAlignIndex = rightAlignIndex;
            if (_leftAlignIndex != -1 && _rightAlignIndex != -1)
            {
                int beginRow = 0;
                int endRow   = 0;
                if (_leftAlignIndex > _rightAlignIndex)
                {
                    endRow = _leftAlignIndex - 1;
                    ((VSheet)_right).PadRowsAt(_rightAlignIndex, (_leftAlignIndex - _rightAlignIndex));
                }
                else
                {
                    endRow = _rightAlignIndex - 1;
                    ((VSheet)_left).PadRowsAt(_leftAlignIndex, (_rightAlignIndex - _leftAlignIndex));
                }

                leftContent.Clear();
                rightContent.Clear();
                {
                    diff_match_patch comparer     = new diff_match_patch();
                    string           leftContent  = _left.GetContent(beginRow, endRow);
                    string           rightContent = _right.GetContent(beginRow, endRow);
                    List <Diff>      diffs        = comparer.diff_main(leftContent, rightContent, true);
                    comparer.diff_cleanupSemantic(diffs);

                    Compare(diffs, beginRow, beginRow);
                }

                leftContent.Clear();
                rightContent.Clear();
                {
                    endRow++;
                    diff_match_patch comparer     = new diff_match_patch();
                    string           leftContent  = _left.GetContent(endRow, endRow);
                    string           rightContent = _right.GetContent(endRow, endRow);
                    List <Diff>      diffs        = comparer.diff_main(leftContent, rightContent, true);
                    comparer.diff_cleanupSemantic(diffs);

                    Compare(diffs, endRow, endRow);
                }

                leftContent.Clear();
                rightContent.Clear();
                {
                    endRow++;
                    diff_match_patch comparer     = new diff_match_patch();
                    string           leftContent  = _left.GetContent(endRow, _left.rowCount - 1);
                    string           rightContent = _right.GetContent(endRow, _right.rowCount - 1);
                    List <Diff>      diffs        = comparer.diff_main(leftContent, rightContent, true);
                    comparer.diff_cleanupSemantic(diffs);

                    Compare(diffs, endRow, endRow);
                }
            }
            else
            {
                diff_match_patch comparer     = new diff_match_patch();
                string           leftContent  = _left.GetContent();
                string           rightContent = _right.GetContent();
                List <Diff>      diffs        = comparer.diff_main(leftContent, rightContent, true);
                comparer.diff_cleanupSemantic(diffs);

                Compare(diffs, 0, 0);
            }

            VSheet leftResult  = new VSheet(_left.name, _columnCount);
            VSheet rightResult = new VSheet(_right.name, _columnCount);

            List <int> deleteList = new List <int>();

            for (int i = 0; i < _rows.Count; i++)
            {
                RowComparer row      = _rows[i];
                IExcelRow   leftRow  = _left.GetRow(row.leftRowIndex);
                IExcelRow   rightRow = _right.GetRow(row.rightRowIndex);
                if (GetRealRowIndex(leftRow) == -1 && GetRealRowIndex(rightRow) == -1)
                {
                    deleteList.Add(i);
                    continue;
                }
                leftResult.NewRow(leftRow);
                rightResult.NewRow(rightRow);
            }

            for (int i = deleteList.Count - 1; i >= 0; i--)
            {
                _rows.RemoveAt(deleteList[i]);
            }

            _left  = leftResult;
            _right = rightResult;
        }
 public IExcelRowParseRequest RowParseRequest(IExcelRow row)
 => RowParseOnTypeRequest(row);
예제 #27
0
 private void FillData(IExcelRow row, SheetRecord sheetRecord)
 {
     Index       = row.Index;
     SheetRecord = sheetRecord;
     CellRecords = row.Cells.Select(x => new CellRecord(x)).ToArray();
 }
예제 #28
0
 public RowRecord(IExcelRow row, SheetRecord sheet, IExcelRowParseResult parseResult)
 {
     FillData(row, sheet);
     FillParseResult(parseResult);
 }
예제 #29
0
 public RowRecord(IExcelRow row, SheetRecord sheet)
 {
     FillData(row, sheet);
 }