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

Bug/extension issue rich data #1781

Merged
merged 2 commits into from
Dec 19, 2024
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
6 changes: 5 additions & 1 deletion src/EPPlus/Drawing/ImageHandling/PictureStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Date Author Change
using OfficeOpenXml.Packaging;
using System.Linq;
using System.Runtime.CompilerServices;
using OfficeOpenXml.Table.PivotTable.Calculation.ShowDataAs;
namespace OfficeOpenXml.Drawing
{
internal class ImageInfo
Expand Down Expand Up @@ -125,7 +126,10 @@ internal ImageInfo AddImage(byte[] image, Uri uri, ePictureType? pictureType)
{
var extension = GetExtension(uri);
contentType = GetContentType(extension);
pictureType = GetPictureType(extension);
if (pictureType.HasValue == false)
{
pictureType = GetPictureType(extension);
}
if (_pck.ZipPackage.PartExists(uri))
{
if(_images.Values.Any(x=>x.Uri.OriginalString==uri.OriginalString))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ public void AddComment()

//ws.Cells["A1"].AddComment("Do Something about this", "ossian");
var sigLine = ws.AddSignatureLine();
sigLine.Sign(cert, "ASigner");
sigLine.SignWithText(cert, "ASigner");

var test = wb.DigitialSignatures[0].Certificate.GetRSAPrivateKey();
var test2 = wb.DigitialSignatures[0].Certificate.GetRSAPrivateKey();
Expand Down
23 changes: 23 additions & 0 deletions src/EPPlusTest/InCellImages/InCellImagesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,28 @@ public void TestImageFormats()
var widthInPixels = measurement.Width;
var heightInPixels = measurement.Height;
}



[TestMethod]
public void testImageInCell()
{
using var p = OpenTemplatePackage(@"c:\epplustest\workbooks\richdata.xlsx");
var ws = p.Workbook.Worksheets[0];
var stockholm = ws.Cells["G1"].Picture.Get();
var text = ws.Cells["F1"].Value;
var text2 = ws.Cells["H1"].Value;
var tokyo = ws.Cells["G2"].Picture.Get();
var dallas = ws.Cells["G3"].Picture.Get();

var ws2 = p.Workbook.Worksheets.Add("Sheet 2");
ws2.Cells["G1"].Picture.Set(stockholm.GetImageBytes());
ws2.Cells["G2"].Picture.Set(tokyo.GetImageBytes());
ws2.Cells["G3"].Picture.Set(dallas.GetImageBytes());

SaveAndCleanup(p);
}


}
}