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”);This renders in excel perfectly.
int pictureIndex = sheet.Pictures.Add(1, 1, ImageUrl);
Aspose.Cells.Drawing.Picture picture = sheet.Pictures[pictureIndex];
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