Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add properties for image dimensions #5

Merged
merged 1 commit into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions EPPlus/Drawing/ExcelPicture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
using System.Drawing;
using System.Drawing.Imaging;
using System.Diagnostics;
using System.Windows;
using OfficeOpenXml.Utils;
using OfficeOpenXml.Compatibility;
using Size = System.Drawing.Size;

namespace OfficeOpenXml.Drawing
{
Expand Down Expand Up @@ -353,6 +355,16 @@ internal string ContentType
get;
set;
}

public Vector GetOffset()
{
return new Vector(_left, _top);
}
public Size GetSize()
{
return new Size(_width, _height);
}

/// <summary>
/// Set the size of the image in percent from the orginal size
/// Note that resizing columns / rows after using this function will effect the size of the picture
Expand Down
24 changes: 23 additions & 1 deletion EPPlus/ExcelWorksheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ public ExcelWorksheet(XmlNamespaceManager ns, ExcelPackage excelPackage, string
_flags = new FlagCellStore();
_commentsStore = new CellStore<int>();
_hyperLinks = new CellStore<Uri>();
_mergedCells = new MergeCellsCollection();

_names = new ExcelNamedRangeCollection(Workbook, this);

Expand Down Expand Up @@ -1111,6 +1112,27 @@ private bool ReadUntil(XmlReader xr, params string[] tagName)
}
return (Utils.ConvertUtil._invariantCompareInfo.IsSuffix(xr.LocalName, tagName[0]));
}
private bool ReadUntil(XmlReader xr, int desiredDepth, params string[] tagName)
{
if (xr.EOF) return false;
while (!Array.Exists(tagName, tag => Utils.ConvertUtil._invariantCompareInfo.IsSuffix(xr.LocalName, tag)))
{
if (xr.Depth == desiredDepth)
{
xr.Read();
if (xr.EOF) return false;
}
else
{
while (xr.Depth != desiredDepth)
{
xr.Read();
if (xr.EOF) return false;
}
}
}
return (Utils.ConvertUtil._invariantCompareInfo.IsSuffix(xr.LocalName, tagName[0]));
}
private void LoadColumns(XmlReader xr)//(string xml)
{
var colList = new List<IRangeID>();
Expand Down Expand Up @@ -1427,7 +1449,7 @@ private bool DoAddRow(XmlReader xr)
/// <param name="xr"></param>
private void LoadMergeCells(XmlReader xr)
{
if (ReadUntil(xr, "mergeCells", "hyperlinks", "rowBreaks", "colBreaks") && !xr.EOF)
if (ReadUntil(xr, 1, "mergeCells", "hyperlinks", "rowBreaks", "colBreaks") && !xr.EOF)
{
while (xr.Read())
{
Expand Down