Skip to content

Commit a100519

Browse files
JanKallmanOssianEPPlusAdrianEPPlusswmalswmal
authored
Merge develop8 1 to develop8 (#2077)
* Moved long running tests to it's own test classes. * Quadtree insert delete-manual merge * Updated cf rule * Fixed insert/delete on ranges for conditional formatting. * Fix in Quadtree * Removed commented out code * Added new functionality to auto fit columns with the WrapText style set. * Added MeasureWrappedTextCells to TextSettings. * Added MeasureWrappedTextCells to ITextMeasurer.MeasureWrappedTextCells * Implemented new interface in GenericFontMetricsTextMeasurer and SystemDrawingTextMeasurer classes. * Updated test * Added fix for 1885 and quad intersect tables (#1953) * Fixed xml comment. * Added more xml comments * Added test for custom table columns (#1952) * Added multiple tests to long-running that were individually 1.2 seconds (#1944) or longer * Feature/shape in chart (#1865) * Shape In Chart hack testing. * fixed hardocded namespaces in drawings when reading. * Adding shape progress * Can now add shapes in chart. * set position and size of shapes in charts * fixed some issues with setsize on shapes in chart. * picture and group shape in chart progress. * groupshape positioning progress * progress * progress * GroupShape in chart progress. It appears to work * added some todo for later * Fixed errors in code from merge. * fixed reading image to chart using stream. * Set position before and after grouping not working properly. * Fixed group shapes in chart. * Ungroup for group shapes in chart. * Shape in chart progress. * fixed version issues from merge * copy groupshape in chart * Fixed bug with drawings id not being read or written properly. * copy chart drawings progress. * copying a chart now properly copies drawings. * Started adding tests for shape in chart * added test for group shapes in chart * More tests * fixed add issue, and resize groupshape bounding box when ungrouping. * Fixed autofit test, fixed horizontal and vertical resolution being 0 in some bmp. * Added missing check for client data node in groupshape * Made a wrapper for ExcelDrawings for chart to hide some add methods. * Fixed some issues with excelchart drawings * added generic pixel to point conversion * fixed image util missing calculation.. * Made DPI standard * Fixed isses from merge. * * Moved Drawings collection from ExcelChart to ExcelChartStandard. * Renamed DrawingsCollectionType.Excel -> DrawingsCollectionType.Worksheet. * Renamed DrawingType -> _collectionType. * Added throw of Exception in ChangeCellAnchor. * Changed tests * Added new eEditAs.RelSize used for Chart shapes * Added resources/images for image files. Removed commented method in ExcelDrawings --------- Co-authored-by: Ossian Edström <[email protected]> Co-authored-by: JanKallman <[email protected]> * Fix/datavalidation copy quadtree (#1949) * Applied quadRange to copying of conditionalformattings. Makine one test twice as fast * Drastically improved performance for data validations * Cleanup comments and unused methods * Fix/header footer text (#1960) * header footer fix * new header footer parsing * HeaderFooter Parsing fixes. * headerfooter progress. * header footer progress. * header footer progress. Need to add remove methods for pictures. * header footer. * headerfooter progress. * Fixed remove of images in the Header & Footer and in the Picture store. * Writing new tests. Fixed vml issue. * Renamed public headerfooter classes, added xml comments. * headerfooter changed static property. * fixed some parsing issues when reading headerfooter text to collection. --------- Co-authored-by: JanKallman <[email protected]> * Bug/i1642 tables and shared formulas (#1956) * Added fix for #1642. Ensured table formula ranges are not shared formulas * Removed irrelevant test for situation * Added test for structured refs * Utils classes sort (Merge after ShapeInChart) (#1896) * Shape In Chart hack testing. * fixed hardocded namespaces in drawings when reading. * Adding shape progress * Can now add shapes in chart. * set position and size of shapes in charts * fixed some issues with setsize on shapes in chart. * picture and group shape in chart progress. * groupshape positioning progress * progress * progress * GroupShape in chart progress. It appears to work * added some todo for later * Fixed errors in code from merge. * fixed reading image to chart using stream. * Set position before and after grouping not working properly. * Fixed group shapes in chart. * Ungroup for group shapes in chart. * Shape in chart progress. * fixed version issues from merge * copy groupshape in chart * Fixed bug with drawings id not being read or written properly. * copy chart drawings progress. * copying a chart now properly copies drawings. * Started adding tests for shape in chart * added test for group shapes in chart * More tests * fixed add issue, and resize groupshape bounding box when ungrouping. * Fixed autofit test, fixed horizontal and vertical resolution being 0 in some bmp. * Added missing check for client data node in groupshape * Made a wrapper for ExcelDrawings for chart to hide some add methods. * Fixed some issues with excelchart drawings * added generic pixel to point conversion * fixed image util missing calculation.. * Made DPI standard * sorted utils classes into folders. * Fixed isses from merge. * fixed issues from merge * * Moved Drawings collection from ExcelChart to ExcelChartStandard. * Renamed DrawingsCollectionType.Excel -> DrawingsCollectionType.Worksheet. * Renamed DrawingType -> _collectionType. * Added throw of Exception in ChangeCellAnchor. * Changed tests * Added new eEditAs.RelSize used for Chart shapes * Added resources/images for image files. Removed commented method in ExcelDrawings * added missing xml comments * Removed wierd auto generated comments * found another comment... --------- Co-authored-by: Ossian Edström <[email protected]> Co-authored-by: JanKallman <[email protected]> * Setting IsPathRelative to false will now save an external workbook with absolulte path in relationship. (#1965) Fixed some minior errors. * Fixed freezing pane not taking hidden rows and columns into considera… (#1969) * Fixed freezing pane not taking hidden rows and columns into consideration. * made fast * Removed a line of code that closes the steam on the part for some charts. * Fixed issue with ChartXml not beeing saved for ExcelChartEx * Fix/i1629 copy columns rows (#1970) * Added start of fix for #1629 * Fixed partial copying of merged cells * Added fixes/tests * Cleaned up unnecesarry comment * Removed faulty method * progress * progress. it appears to work. * optimized and reduced repeating code. * clarity * changed to AddFormulaNoValidation since it's done on on the worksheet names. * Fix for #1656 (#1973) * Fix for #1656 * Simplified Copy logic and added possiblity to copy to multiple destinations * Removed unnecesary comment * Simplified copyOnly for fill and transpose * Fixed datavalidation copy issue * Created better name for simplified enum * Applied re-name properly * Added new add methods and set methods for defined names. * Added method to update formula strings so addresses have reference to worksheet * progress * progress * Added repeatable test for both wb and ws * Fixed file after merge * Fix/i267 (#2019) * added test * Collection Multiple tests and methods draft for axis change * Cleaned tests. Clarified comments for Fill * Added a more limited modular axisType changer * added handling of bar area and start of xy cha * Added scatter chart, removed unnecesary code * Removed unnecesary comments * Cleaned up * Bug/s870 (#2013) * Added alternative binary search in comments * Attempt at solution based on existing values * Dimension by range start * Functional lookup binary * Fixed failing tests * Comment cleanup * Broke out solution to static class * Changed to simpleAddress * fixed bugs * Removed unnecesary test * fixed comment. Clarified name * fixewd errors * Fixed chart axis tests * Fixed an issue with DimensionByValue * Fixed test * Fixed issue with ConvertUtil namespace * Fixed failing test * Fixed test and added 2 get mehtods for value and formula * Removed Validation of worksheetname and cell address in Names for External refs * Fixed column range issues (#2060) * Fixed column range issues * Ensured advanced CFs update cell-references on insert/delete * Copy workbook scope defined names if referenced in a workbook when copying a worksheet. * Fixed test for external reference to set the IsPathRelative = false * Fix/defnam (#2065) * fixed some defined name issues. * fixed more issue. * removed null check on worksheet for defined name validation. * Fix for Shapes in charts to support absolute positioning * Fixed merge issues. Fixed handling of Group Shapes in Charts * Fix for group shapes. Fixed test * Fixed for shapes in charts * Fixed some issues with absolute Shapes in charts * Fix/freeze panes hidden cells (#2067) * Fixed several bugs related to Freeze panes with hidden row/col * Added documentation comment and made test less repetitive * Ensured freezepanes does not iterate unnecesarily * Fixed copying of defined names. Fixed an issue when copying dynamic array formula * Fixed Index property of names when copying worksheet * Increased accptable time for cell store perforance test, so low performance appveyor builds shouldn't fail * Fixed faulty column iteration (#2074) * Fixed faulty column iteration * Removed unnecesary comment * Removed add signature for formulas. * Removed Move and Copy methods from ExcelNamedRange for now. Needs more validation. Removed validation on NameFormula.Removed related tests. --------- Co-authored-by: OssianEPPlus <[email protected]> Co-authored-by: AdrianEPPlus <[email protected]> Co-authored-by: Ossian Edström <[email protected]> Co-authored-by: swmal <[email protected]> Co-authored-by: AdrianParnéus <[email protected]> Co-authored-by: swmal <{ID}+username}@users.noreply.github.com>
1 parent 4e38e58 commit a100519

File tree

459 files changed

+10318
-3194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

459 files changed

+10318
-3194
lines changed

appveyor8.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
version: 8.0.8.{build}
1+
version: 8.1.0.{build}
22
branches:
33
only:
44
- develop8
55
configuration: release
66
image: Visual Studio 2022
77
init:
88
- ps: >-
9-
Update-AppveyorBuild -Version "8.0.8.$env:appveyor_build_number-$(Get-Date -format yyyyMMdd)-$env:appveyor_repo_branch"
9+
Update-AppveyorBuild -Version "8.1.0.$env:appveyor_build_number-$(Get-Date -format yyyyMMdd)-$env:appveyor_repo_branch"
1010
11-
Write-Host "8.0.8.$env:appveyor_build_number-$(Get-Date -format yyyyMMdd)-$env:appveyor_repo_branch"
11+
Write-Host "8.1.0.$env:appveyor_build_number-$(Get-Date -format yyyyMMdd)-$env:appveyor_repo_branch"
1212
dotnet_csproj:
1313
patch: true
1414
file: '**\*.csproj'
1515
version: '{version}'
16-
assembly_version: 8.0.8.{build}
17-
file_version: 8.0.8.{build}
16+
assembly_version: 8.1.0.{build}
17+
file_version: 8.1.0.{build}
1818
nuget:
1919
project_feed: true
2020
before_build:

src/EPPlus.Interfaces/Drawing/Text/ITextMeasurer.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,10 @@ public interface ITextMeasurer
3030
/// <param name="font">The <see cref="MeasurementFont">font</see> to measure</param>
3131
/// <returns></returns>
3232
TextMeasurement MeasureText(string text, MeasurementFont font);
33+
/// <summary>
34+
/// If the text measurer should measure wrap text cells.
35+
/// Only CR, LF or CRLF should be considered.
36+
/// </summary>
37+
bool MeasureWrappedTextCells { get; set; }
3338
}
3439
}

src/EPPlus.System.Drawing/Drawing/Text/SystemDrawingTextMeasurer.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,20 @@ namespace OfficeOpenXml.SystemDrawing.Text
88
#pragma warning disable CA1416 // Platform compatibility warning
99
public class SystemDrawingTextMeasurer : ITextMeasurer, IDisposable
1010
{
11+
/// <summary>
12+
/// If the text measurer should measure wrap text cells.
13+
/// Only CR, LF or CRLF should be considered.
14+
/// </summary>
15+
public bool MeasureWrappedTextCells
16+
{
17+
get;
18+
set;
19+
}
1120
public SystemDrawingTextMeasurer()
1221
{
1322
if (Environment.OSVersion.Platform == PlatformID.Win32NT &&
1423
Environment.OSVersion.Version.Major >= 6 &&
15-
Environment.OSVersion.Version.Minor >= 1)
24+
Environment.OSVersion.Version.Minor >= 0)
1625
{
1726
_stringFormat = StringFormat.GenericDefault;
1827
_bmp = new Bitmap(1, 1);
@@ -81,7 +90,7 @@ public TextMeasurement MeasureText(string text, MeasurementFont font)
8190
float dpiCorrectX, dpiCorrectY;
8291
try
8392
{
84-
//Check for missing GDI+, then use WPF istead.
93+
//Check for missing GDI+, then use WPF instead.
8594
_graphics.PageUnit = GraphicsUnit.Pixel;
8695
dpiCorrectX = 96 / _graphics.DpiX;
8796
dpiCorrectY = 96 / _graphics.DpiY;

src/EPPlus/CellPictures/CellPicturesManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Date Author Change
1818
using OfficeOpenXml.RichData.RichValues.LocalImage;
1919
using OfficeOpenXml.RichData.RichValues.WebImages;
2020
using OfficeOpenXml.RichData.Structures.Constants;
21-
using OfficeOpenXml.Utils;
21+
using OfficeOpenXml.Utils.FileUtils;
2222
using System;
2323
using System.IO;
2424
using System.Linq;

src/EPPlus/ConditionalFormatting/ColorScaleReadHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Date Author Change
1111
01/27/2020 EPPlus Software AB Initial release EPPlus 5
1212
07/07/2023 EPPlus Software AB Epplus 7
1313
*************************************************************************************************/
14-
using OfficeOpenXml.Utils.Extensions;
14+
using OfficeOpenXml.Utils.EnumUtils;
1515
using System.Xml;
1616

1717
namespace OfficeOpenXml.ConditionalFormatting

src/EPPlus/ConditionalFormatting/ExcelConditionalFormattingCollection.cs

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ Date Author Change
1212
07/07/2023 EPPlus Software AB Epplus 7
1313
*************************************************************************************************/
1414
using OfficeOpenXml.ConditionalFormatting.Contracts;
15+
using OfficeOpenXml.Core.RangeQuadTree;
1516
using OfficeOpenXml.Utils;
16-
using OfficeOpenXml.Utils.Extensions;
17+
using OfficeOpenXml.Utils.EnumUtils;
18+
using OfficeOpenXml.Utils.XML;
1719
using System;
1820
using System.Collections;
1921
using System.Collections.Generic;
@@ -34,11 +36,20 @@ public class ExcelConditionalFormattingCollection : IEnumerable<IExcelConditiona
3436
int LastPriority = 1;
3537
//A dict for those conditionalFormattings that are Ext, have been read in locally but not yet read in their ExtLst parts.
3638
internal Dictionary<string, ExcelConditionalFormattingRule> localAndExtDict = new Dictionary<string, ExcelConditionalFormattingRule>();
39+
internal QuadTree<IExcelConditionalFormattingRule> CfIndex { get; set; }
3740

3841
internal ExcelConditionalFormattingCollection(ExcelWorksheet ws)
3942
{
4043
_ws = ws;
4144
_rules = new List<ExcelConditionalFormattingRule>();
45+
if(_ws.Dimension==null)
46+
{
47+
CfIndex = new QuadTree<IExcelConditionalFormattingRule>();
48+
}
49+
else
50+
{
51+
CfIndex = new QuadTree<IExcelConditionalFormattingRule>(_ws.Dimension);
52+
}
4253
}
4354

4455
internal void ReadRegularConditionalFormattings(XmlReader xr)
@@ -66,10 +77,6 @@ internal void ReadRegularConditionalFormattings(XmlReader xr)
6677

6778
if (xr.LocalName == "cfRule" && xr.NodeType == XmlNodeType.Element)
6879
{
69-
//if (xr.LocalName == "conditionalFormatting")
70-
//{
71-
// xr.Read();
72-
//}
7380
ExcelConditionalFormattingRule cf;
7481

7582
if (string.IsNullOrEmpty(address))
@@ -88,7 +95,7 @@ internal void ReadRegularConditionalFormattings(XmlReader xr)
8895
}
8996
else
9097
{
91-
_rules.Add(cf);
98+
AddToList(cf);
9299
}
93100
}
94101
while ((xr.LocalName == "conditionalFormatting" || xr.LocalName == "cfRule") && xr.NodeType == XmlNodeType.EndElement) xr.Read();
@@ -236,7 +243,7 @@ internal void ReadExtConditionalFormattings(XmlReader xr)
236243
dataBar.NegativeBarColorSameAsPositive = negativeBarColorSameAsPositive.Value;
237244
}
238245

239-
_rules.Add(dataBar);
246+
AddToList(dataBar);
240247
dataBar.Uid = id;
241248
}
242249
else if (xr.GetAttribute("type") == "iconSet")
@@ -395,7 +402,7 @@ internal void ReadExtConditionalFormattings(XmlReader xr)
395402
{
396403
var cf = ExcelConditionalFormattingRuleFactory.Create(null, _ws, xr);
397404
cf.Uid = id;
398-
_rules.Add(cf);
405+
AddToList(cf);
399406

400407
if (cf.Address == null)
401408
{
@@ -494,7 +501,7 @@ internal void CopyRule(ExcelConditionalFormattingRule rule, ExcelAddress address
494501
{
495502
ruleCopy.Address = address;
496503
}
497-
_rules.Add(ruleCopy);
504+
AddToList(ruleCopy);
498505
}
499506

500507
IEnumerator<IExcelConditionalFormattingRule> IEnumerable<IExcelConditionalFormattingRule>.GetEnumerator()
@@ -553,6 +560,7 @@ public void Remove(
553560
try
554561
{
555562
_rules.Remove((ExcelConditionalFormattingRule)item);
563+
CfIndex.Clear(item.Address, item);
556564
}
557565
catch
558566
{
@@ -664,12 +672,17 @@ internal IExcelConditionalFormattingRule AddRule(
664672
_ws);
665673

666674
// Add the newly created rule to the list
667-
_rules.Add(cfRule);
675+
AddToList(cfRule);
668676

669677
// Return the newly created rule
670678
return cfRule;
671679
}
672680

681+
private void AddToList(ExcelConditionalFormattingRule cfRule)
682+
{
683+
_rules.Add(cfRule);
684+
}
685+
673686
internal void ClearTempExportCacheForAllCFs()
674687
{
675688
foreach(var cf in _rules)
@@ -1890,5 +1903,17 @@ internal IExcelConditionalFormattingRule GetByPriority(int priority)
18901903
}
18911904
return null;
18921905
}
1906+
1907+
internal List<QuadRangeItem<IExcelConditionalFormattingRule>> GetIntersectingRanges(ExcelAddress address)
1908+
{
1909+
if(_rules.Count > 0)
1910+
{
1911+
return CfIndex.GetIntersectingRangeItems(new QuadRange(address));
1912+
}
1913+
else
1914+
{
1915+
return new List<QuadRangeItem<IExcelConditionalFormattingRule>>();
1916+
}
1917+
}
18931918
}
18941919
}

src/EPPlus/ConditionalFormatting/ExcelConditionalFormattingHelper.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ Date Author Change
1919
using System.Drawing;
2020
using System.Globalization;
2121
using System.Xml;
22+
using OfficeOpenXml.Utils.TypeConversion;
2223

2324
namespace OfficeOpenXml.ConditionalFormatting
2425
{
25-
/// <summary>
26-
/// Conditional formatting helper
27-
/// </summary>
28-
internal static class ExcelConditionalFormattingHelper
26+
/// <summary>
27+
/// Conditional formatting helper
28+
/// </summary>
29+
internal static class ExcelConditionalFormattingHelper
2930
{
3031
/// <summary>
3132
/// Check and fix an address (string address)

src/EPPlus/ConditionalFormatting/ExcelConditionalFormattingIconSetBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ Date Author Change
1616
using System.Xml;
1717
using OfficeOpenXml.ConditionalFormatting.Contracts;
1818
using OfficeOpenXml.FormulaParsing.Utilities;
19-
using OfficeOpenXml.Utils;
20-
using OfficeOpenXml.Utils.Extensions;
2119
using System.Collections.Generic;
2220
using System.Linq;
2321
using OfficeOpenXml.Table.PivotTable;
2422
using OfficeOpenXml.ConditionalFormatting.Rules;
23+
using OfficeOpenXml.Utils.TypeConversion;
24+
using OfficeOpenXml.Utils.EnumUtils;
2525

2626
namespace OfficeOpenXml.ConditionalFormatting
2727
{

src/EPPlus/ConditionalFormatting/ExcelConditionalFormattingRuleFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Date Author Change
1313
*************************************************************************************************/
1414
using OfficeOpenXml.ConditionalFormatting.Rules;
1515
using OfficeOpenXml.Utils;
16-
using OfficeOpenXml.Utils.Extensions;
16+
using OfficeOpenXml.Utils.EnumUtils;
1717
using System;
1818
using System.Xml;
1919

src/EPPlus/ConditionalFormatting/RangeConditionalFormatting.cs

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ Date Author Change
1616
using System.Collections.Generic;
1717
using OfficeOpenXml.Core.RangeQuadTree;
1818
using System;
19+
using System.Linq;
1920

2021
namespace OfficeOpenXml.ConditionalFormatting
2122
{
2223
internal class RangeConditionalFormatting
2324
: IRangeConditionalFormatting
2425
{
2526
#region Public Properties
26-
public ExcelWorksheet _worksheet;
27-
public ExcelAddress _address;
27+
private ExcelWorksheet _worksheet;
28+
private ExcelAddress _address;
2829
#endregion Public Properties
2930

3031
#region Constructors
@@ -511,32 +512,25 @@ public IExcelConditionalFormattingDataBarGroup AddDatabar(System.Drawing.Color C
511512
#endregion Conditional Formatting Rule Types
512513

513514
#region Public Methods
515+
/// <summary>
516+
/// Gets all conditional formatting rules intersecting whith the range.
517+
/// </summary>
518+
/// <returns>A list of formatting rules</returns>
514519
public List<ExcelConditionalFormattingRule> GetConditionalFormattings()
515520
{
516-
var retList = new List<ExcelConditionalFormattingRule>();
517-
518-
foreach (var cf in _worksheet.ConditionalFormatting)
521+
var hs = new HashSet<ExcelConditionalFormattingRule>();
522+
var l = _worksheet.ConditionalFormatting.GetIntersectingRanges(_address);
523+
foreach(var i in l)
519524
{
520-
if(cf.Address.Addresses==null)
525+
var v = (ExcelConditionalFormattingRule)i.Value;
526+
if (!hs.Contains(v))
521527
{
522-
if (cf.Address.Collide(_address) != ExcelAddressBase.eAddressCollition.No)
523-
{
524-
retList.Add((ExcelConditionalFormattingRule)cf);
525-
}
526-
}
527-
else
528-
{
529-
foreach (var a in cf.Address.Addresses)
530-
{
531-
if (a.Collide(_address) != ExcelAddressBase.eAddressCollition.No)
532-
{
533-
retList.Add((ExcelConditionalFormattingRule)cf);
534-
}
535-
}
528+
hs.Add(v);
536529
}
537530
}
538-
return retList;
531+
return hs.OrderBy(x=>x.Priority).ToList();
539532
}
533+
540534
#endregion Public Methods
541535
}
542536
}

0 commit comments

Comments
 (0)