Skip to content
This repository has been archived by the owner on Mar 9, 2020. It is now read-only.

Bugfix/biwebsvody 8848 #514

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
7a7099d
Доработано копирование объединений
Feb 15, 2019
5da5970
[*] Добавлены проверки при удалении комментариев
Feb 22, 2019
c7902b2
[*] Исправлена ошибка при работе с объединенными ячейками
Feb 25, 2019
4f3a917
[*] Исключена очистка некорректных формул,
Mar 19, 2019
2711396
[*] Доработано копирование xlsx, имеющих в составе макросы VBA
Mar 19, 2019
e0c4349
[*] fix Исправлено копирование стилей
Mar 19, 2019
5c4c97f
[*] fix Исправлена ошибка при операции с объединенными ячейками
Mar 19, 2019
8e8b8aa
[*] Исправлены ошибки при работе с sharedformulas
Mar 25, 2019
d618502
Update .gitignore
Mar 25, 2019
1ac41a4
[*] Исправлена ошибка обработки комментариев
Mar 29, 2019
e46b0d5
[*] Оптимизирована логика работы с объединениями; реалзована возможно…
Apr 11, 2019
a7c09e5
Исправлена ошибка кэширования объединенных ячеек при копировании диап…
May 22, 2019
d64ccbe
[#BIWEBSVODY-8848] Добавлен пропуск именованных ячеек с некорректным …
Jul 22, 2019
0b85250
[#BIWEBSVODY-8848] Объединил условия
Jul 22, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,12 @@ _ReSharper*/
~$*

#NuGet
packages/
packages/
.idea/.idea.EPPlus/.idea/contentModel.xml
.idea/.idea.EPPlus/.idea/encodings.xml
.idea/.idea.EPPlus/.idea/indexLayout.xml
.idea/.idea.EPPlus/.idea/misc.xml
.idea/.idea.EPPlus/.idea/modules.xml
.idea/.idea.EPPlus/.idea/vcs.xml
.idea/.idea.EPPlus/.idea/workspace.xml
.idea/.idea.EPPlus/riderModule.iml
10 changes: 9 additions & 1 deletion EPPlus/Drawing/Vml/ExcelVmlDrawingCommentCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,15 @@ private XmlNode AddDrawing(ExcelRangeBase cell)
{
ix = ~ix;
var prevDraw = _drawings[ix] as ExcelVmlDrawingBase;
prevDraw.TopNode.ParentNode.InsertBefore(node, prevDraw.TopNode);
var parentNode = prevDraw.TopNode.ParentNode;
if (parentNode!=null)
{
parentNode.InsertBefore(node, prevDraw.TopNode);
}
else
{
VmlDrawingXml.DocumentElement.AppendChild(node);
}
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion EPPlus/EPPlus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand Down
11 changes: 8 additions & 3 deletions EPPlus/ExcelCommentCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,15 @@ public void Remove(ExcelComment comment)
}
if (comment==c)
{
comment.TopNode.ParentNode.RemoveChild(comment.TopNode); //Remove VML
comment._commentHelper.TopNode.ParentNode.RemoveChild(comment._commentHelper.TopNode); //Remove Comment
//
comment.TopNode.ParentNode?.RemoveChild(comment.TopNode); //Remove VML
comment._commentHelper.TopNode.ParentNode?.RemoveChild(comment._commentHelper.TopNode); //Remove Comment

if (Worksheet.VmlDrawingsComments._drawings.ContainsKey(id))
{
Worksheet.VmlDrawingsComments._drawings.Delete(id);
}

Worksheet.VmlDrawingsComments._drawings.Delete(id);
_list.RemoveAt(i);
Worksheet._commentsStore.Delete(comment.Range._fromRow, comment.Range._fromCol, 1, 1, false); //Issue 15549, Comments should not be shifted
var ci = new CellsStoreEnumerator<int>(Worksheet._commentsStore);
Expand Down
52 changes: 31 additions & 21 deletions EPPlus/ExcelRangeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,11 @@ private static void Set_StyleName(ExcelRangeBase range, object value, int row, i
private static void Set_Value(ExcelRangeBase range, object value, int row, int col)
{
var sfi = range._worksheet._formulas.GetValue(row, col);
if (sfi is int)
if (sfi is int && !range.IsSingleCell)
{
range.SplitFormulas(range._worksheet.Cells[row, col]);
}
if (sfi != null) range._worksheet._formulas.SetValue(row, col, string.Empty);
// if (sfi != null) range._worksheet._formulas.SetValue(row, col, string.Empty);
range._worksheet.SetValueInner(row, col, value);
}
private static void Set_Formula(ExcelRangeBase range, object value, int row, int col)
Expand Down Expand Up @@ -1270,7 +1270,11 @@ public bool Merge
set
{
IsRangeValid("merging");
_worksheet.MergedCells.Clear(this);
if (!_worksheet.DisableMergeValidation)
{
_worksheet.MergedCells.Clear(this);
}

if (value)
{
_worksheet.MergedCells.Add(new ExcelAddressBase(FirstAddress), true);
Expand Down Expand Up @@ -1608,7 +1612,7 @@ private void SplitFormula(ExcelAddressBase address, int ix)
//The formula is inside the currenct range, remove it
if (collide == eAddressCollition.Equal || collide == eAddressCollition.Inside)
{
_worksheet._sharedFormulas.Remove(ix);
// _worksheet._sharedFormulas.Remove(ix);
return;
//fRange.SetSharedFormulaID(int.MinValue);
}
Expand Down Expand Up @@ -2609,29 +2613,35 @@ public void Copy(ExcelRangeBase Destination, ExcelRangeCopyOptionFlags? excelRan
}
var copiedMergedCells = new Dictionary<int, ExcelAddress>();
//Merged cells
var csem = new CellsStoreEnumerator<int>(_worksheet.MergedCells._cells, _fromRow, _fromCol, _toRow, _toCol);
while (csem.Next())

for (var row = _fromRow; row <= _toRow; row++)
{
if (!copiedMergedCells.ContainsKey(csem.Value))
for (var col = _fromCol; col <= _toCol; col++)
{
var adr = new ExcelAddress(_worksheet.Name, _worksheet.MergedCells.List[csem.Value]);
var collideResult = Collide(adr);
if (collideResult == eAddressCollition.Inside || collideResult == eAddressCollition.Equal)
{
copiedMergedCells.Add(csem.Value, new ExcelAddress(
Destination._fromRow + (adr.Start.Row - _fromRow),
Destination._fromCol + (adr.Start.Column - _fromCol),
Destination._fromRow + (adr.End.Row - _fromRow),
Destination._fromCol + (adr.End.Column - _fromCol)));
}
else
var key = _worksheet.GetMergeCellId(row, col) - 1;
if (key >= 0 && !copiedMergedCells.ContainsKey(key))
{
//Partial merge of the address ignore.
copiedMergedCells.Add(csem.Value, null);
var adr = new ExcelAddress(_worksheet.Name, _worksheet.MergedCells.List[key]);
var collideResult = Collide(adr);
if (collideResult == eAddressCollition.Inside || collideResult == eAddressCollition.Equal)
{
copiedMergedCells.Add(
key,
new ExcelAddress(
Destination._fromRow + (adr.Start.Row - _fromRow),
Destination._fromCol + (adr.Start.Column - _fromCol),
Destination._fromRow + (adr.End.Row - _fromRow),
Destination._fromCol + (adr.End.Column - _fromCol)));
}
else
{
//Partial merge of the address ignore.
copiedMergedCells.Add(key, null);
}
}
}
}

Destination._worksheet.MergedCells.Clear(new ExcelAddressBase(Destination._fromRow, Destination._fromCol, Destination._fromRow + toRow - 1, Destination._fromCol + toCol - 1));

Destination._worksheet._values.Clear(Destination._fromRow, Destination._fromCol, toRow, toCol);
Expand Down
3 changes: 2 additions & 1 deletion EPPlus/ExcelStyles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,7 @@ internal int CloneStyle(ExcelStyles style, int styleID, bool isNamedStyle, bool
xfs = style.CellXfs[styleID];
}
ExcelXfs newXfs = xfs.Copy(this);
newXfs.XfId = 0;
//Numberformat
if (xfs.NumberFormatId > 0)
{
Expand Down Expand Up @@ -1026,7 +1027,7 @@ internal int CloneStyle(ExcelStyles style, int styleID, bool isNamedStyle, bool
}

//Named style reference
if (xfs.XfId > 0)
if (isNamedStyle && xfs.XfId > 0)
{
var id = style.CellStyleXfs[xfs.XfId].Id;
var newId = CellStyleXfs.FindIndexByID(id);
Expand Down
5 changes: 5 additions & 0 deletions EPPlus/ExcelWorkbook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ internal void GetDefinedNames()
{
string fullAddress = elem.InnerText;

if(fullAddress.EndsWith("!#REF!"))
{
continue;
}

int localSheetID;
ExcelWorksheet nameWorksheet;

Expand Down
Loading