Skip to content

Commit 602107f

Browse files
committed
Fixed small error in positioning of shapes in charts
1 parent f1e5ea0 commit 602107f

2 files changed

Lines changed: 31 additions & 3 deletions

File tree

src/EPPlus/Drawing/ExcelDrawing.cs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,21 @@ internal void SetPixelTop(double pixels)
924924
_doNotAdjust = true;
925925
if (CellAnchor == eEditAs.Absolute)
926926
{
927-
Position.Y = (int)(pixels * EMU_PER_PIXEL);
927+
if (_drawings._collectionType == DrawingsCollectionType.Chart)
928+
{
929+
if (From == null)
930+
{
931+
Position.Y = (int)(pixels * EMU_PER_PIXEL);
932+
}
933+
else
934+
{
935+
From.Y = pixels / _drawings._screenHeight;
936+
}
937+
}
938+
else
939+
{
940+
Position.Y = (int)(pixels * EMU_PER_PIXEL);
941+
}
928942
}
929943
else
930944
{
@@ -966,7 +980,21 @@ internal void SetPixelLeft(double pixels)
966980
_doNotAdjust = true;
967981
if (CellAnchor == eEditAs.Absolute)
968982
{
969-
Position.X = (int)(pixels * EMU_PER_PIXEL);
983+
if (_drawings._collectionType == DrawingsCollectionType.Chart)
984+
{
985+
if(From==null)
986+
{
987+
Position.X = (int)(pixels * EMU_PER_PIXEL);
988+
}
989+
else
990+
{
991+
From.X = pixels / _drawings._screenWidth;
992+
}
993+
}
994+
else
995+
{
996+
Position.X = (int)(pixels * EMU_PER_PIXEL);
997+
}
970998
}
971999
else
9721000
{

src/EPPlusTest/TestBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ protected static void SaveWorkbook(string name, ExcelPackage pck)
249249
var fi = new FileInfo(_worksheetPath + name);
250250
if (fi.Exists)
251251
{
252-
fi.Delete();
252+
fi.Delete();
253253
}
254254
pck.SaveAs(fi);
255255
}

0 commit comments

Comments
 (0)