Can't get images to render in HTML - but rendering in Excel just fine

I am trying to create code that takes a datatable, parses through it and generates it in either into an excel spreadsheet, or an html page depending on user selection.

I have already successfully accomplished this using the Aspose tools. However, I am having difficulty getting it to render images correctly.

Images always render perfectly in the excel spreadsheet. But when I try to render using the aspose html generator the images always show up as broken links. Something to note is that in the rendered html the links are not relative links, they are always links to a location on C:\ like this:



I tried to follow these steps:


string ImageUrl = System.Web.HttpContext.Current.Server.MapPath(“~/Image/school.JPG”);
int pictureIndex = sheet.Pictures.Add(1, 1, ImageUrl);
Aspose.Cells.Drawing.Picture picture = sheet.Pictures[pictureIndex];
This renders in excel perfectly.

I have a Worksheet object named worksheet_;
worksheet_.Pictures.Add(firstRow, firstColumn, imageUrl);
Then the save of course to my workbook object:
public MemoryStream ToStream() {
MemoryStream stream = new MemoryStream();
workbook_.Save(stream, FileFormatAdapter.ToSaveFormat(workbook_.FileFormat));
return stream;
}

FileFormatAdapter.ToSaveFormat returns SaveFormat.Html or SaveFormat.Xlsx


Hi,


I have tested your case using our latest version/fix: Aspose.Cells for .NET v7.3.3.4, it works fine. I tested it with a simple template file having a picture in it, the picture does render fine in HTML file.


Please try the fix(v7.3.3.4) and let us know your result.

Thank you.

Unfortunately the new dll did not work :frowning:

I am getting the same result.

Could you upload your sample code?

Could this have to do with security/permissions on the folder that the tag is trying to pull the images from?

Hi,


Well, I just opened a sample file (containing a picture in it) and converted to HTML file format using the sample code below:

Sample code:

Workbook workbook = new Workbook(@“E:\test2\Book1.xlsx”);
workbook.Save(@“E:\test2\outputBook1.html”, SaveFormat.Html);

Could you give us sample runnable code/sample application (you may zip it prior attaching it here) with your image(s) and template files, we will check your issue soon.

Thank you.