diff --git a/ClosedXML/Excel/Drawings/IXLPicture.cs b/ClosedXML/Excel/Drawings/IXLPicture.cs
index 15d6b2a..857488f 100644
--- a/ClosedXML/Excel/Drawings/IXLPicture.cs
+++ b/ClosedXML/Excel/Drawings/IXLPicture.cs
@@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using System.IO;
+using DocumentFormat.OpenXml.Packaging;
namespace ClosedXML.Excel.Drawings
{
@@ -23,6 +24,17 @@
long RawOffsetY { get; set; }
bool IsAbsolute { get; set; }
+ ///
+ /// Type of image. The supported formats are defined by OpenXML's ImagePartType.
+ /// Default value is "jpeg"
+ ///
+ String Type { get; set; }
+
String Name { get; set; }
+
+ ///
+ /// Get the enum representation of the Picture type.
+ ///
+ ImagePartType GetImagePartType();
}
}
diff --git a/ClosedXML/Excel/Drawings/XLPicture.cs b/ClosedXML/Excel/Drawings/XLPicture.cs
index ea5943a..edaea9a 100644
--- a/ClosedXML/Excel/Drawings/XLPicture.cs
+++ b/ClosedXML/Excel/Drawings/XLPicture.cs
@@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using System.IO;
+using DocumentFormat.OpenXml.Packaging;
namespace ClosedXML.Excel.Drawings
{
@@ -12,6 +13,7 @@
private List Markers;
private String name;
private bool isAbsolute;
+ private ImagePartType type = ImagePartType.Jpeg;
private long iMaxWidth = 500;
private long iMaxHeight = 500;
@@ -209,5 +211,34 @@
isAbsolute = value;
}
}
+
+ public String Type
+ {
+ get
+ {
+ return GetExtension(type);
+ }
+ set
+ {
+ try
+ {
+ type = (ImagePartType)Enum.Parse(typeof(ImagePartType), value, true);
+ }
+ catch
+ {
+ type = ImagePartType.Jpeg;
+ }
+ }
+ }
+
+ private String GetExtension(ImagePartType type)
+ {
+ return type.ToString();
+ }
+
+ public ImagePartType GetImagePartType()
+ {
+ return type;
+ }
}
}
diff --git a/ClosedXML/Excel/XLWorkbook_Save.cs b/ClosedXML/Excel/XLWorkbook_Save.cs
index 8e2cd4f..0237a65 100644
--- a/ClosedXML/Excel/XLWorkbook_Save.cs
+++ b/ClosedXML/Excel/XLWorkbook_Save.cs
@@ -2517,7 +2517,8 @@
var worksheetDrawing = drawingsPart.WorksheetDrawing;
- var imagePart = drawingsPart.AddImagePart(ImagePartType.Png, GeneratePartId(picture.Name, drawingsPart));
+ var imagePart = drawingsPart.AddImagePart(picture.GetImagePartType(),
+ GeneratePartId(picture.Name, drawingsPart));
using (Stream stream = new MemoryStream())
{
diff --git a/ClosedXML_Examples/ClosedXML_Examples.csproj b/ClosedXML_Examples/ClosedXML_Examples.csproj
index 6e3a510..de7cb8e 100644
--- a/ClosedXML_Examples/ClosedXML_Examples.csproj
+++ b/ClosedXML_Examples/ClosedXML_Examples.csproj
@@ -77,6 +77,7 @@
+
@@ -181,6 +182,9 @@
+
+
+