Quantcast
Channel: EPPlus Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 2262

Commented Unassigned: Not possible to unmerge in 4.0.1 [15134]

$
0
0
Dears,
It is no longer possible use Merge property to unmerge a range:

In version 4.0.1 (In ExcelRangeBase.cs):

> ExcelRange.Merge = false

has same effect as

> ExcelRange.Merge = true

Should there be other way how to unmerge? Or it is planned to be added? Or it is a bug?

Thank you

Meanwhile I have updated the setter of Merge property in my project to code below:

```
set
{
IsRangeValid("merging");
//SetMerge(value, FirstAddress);
if (!value)
{
if (_worksheet.MergedCells.Contains(FirstAddress))
{
_worksheet.MergedCells.Remove(FirstAddress);
}
else
{
throw (new ArgumentException("Range is not merged"));
}
if (Addresses != null)
{
foreach (var address in Addresses)
{
if (_worksheet.MergedCells.Contains(address.Address))
{
_worksheet.MergedCells.Remove(address.Address);
}
else
{
throw (new ArgumentException("Range is not merged"));
}
}
}
}
else
{
_worksheet.MergedCells.Add(new ExcelAddressBase(FirstAddress), true);
if (Addresses != null)
{
foreach (var address in Addresses)
{
_worksheet.MergedCells.Add(address, true);
//SetMerge(value, address._address);
}
}
}
}
```
Comments: I think that you need clear the cells, like this ``` set { IsRangeValid("merging"); //SetMerge(value, FirstAddress); if (!value) { if (_worksheet.MergedCells.Contains(FirstAddress)) { _worksheet.MergedCells.Remove(FirstAddress); ExcelAddress a = new ExcelAddress(FirstAddress); _worksheet.MergedCells._cells.Clear(a._fromRow, a._fromCol, a._toRow, a._toCol); } else { throw (new ArgumentException("Range is not merged")); } if (Addresses != null) { foreach (var address in Addresses) { if (_worksheet.MergedCells.Contains(address.Address)) { _worksheet.MergedCells.Remove(address.Address); ExcelAddress a = new ExcelAddress(address.Address); _worksheet.MergedCells._cells.Clear(a._fromRow, a._fromCol, a._toRow, a._toCol); } else { throw (new ArgumentException("Range is not merged")); } } } } else { _worksheet.MergedCells.Add(new ExcelAddressBase(FirstAddress), true); if (Addresses != null) { foreach (var address in Addresses) { _worksheet.MergedCells.Add(address, true); //SetMerge(value, address._address); } } } } ```

Viewing all articles
Browse latest Browse all 2262

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>