Embedded picture in Excel cell was not correclty managed

Hello,

We are a software publisher using your library for our Web application.
We are encountering a problem when previewing a Excel file, which a cell contains embedded picture.

Here, we can found the document in this zip test35093.7z (229.5 KB) and the screen of preview file image.jpg (83.3 KB)

Here’s the code used for the preview

using GroupDocs.Viewer.Options;
using GroupDocs.Viewer.Results;
using System;
using System.IO;

namespace Web.code.Lib.GroupDocsViewer
{
    public class HtmlViewer : IDisposable
    {
        private readonly GroupDocs.Viewer.Viewer viewer;
        private readonly HtmlViewOptions htmlViewOptions;
        private readonly ViewInfoOptions viewInfoOptions;

        private Stream stream;

        public HtmlViewer(string filePath, LoadOptions loadOptions)
        {
            viewer = new GroupDocs.Viewer.Viewer(filePath, loadOptions);
            htmlViewOptions = CreateHtmlViewOptions();
            viewInfoOptions = ViewInfoOptions.FromHtmlViewOptions(htmlViewOptions);
        }

        private HtmlViewOptions CreateHtmlViewOptions()
        {
            HtmlViewOptions htmlViewOptions = HtmlViewOptions.ForEmbeddedResources(
                // The action that will be done before each page informations is read
                pageNumber =>
                {
                    Stream pageStream = new MemoryStream();
                    stream = pageStream;

                    return pageStream;
                },
                // The action to do after each page information is read.
                // Must be there otherwise the stream is disposed and we can't used it anymore
                (pageNumber, stream) =>
                {
                });

            htmlViewOptions.SpreadsheetOptions = SpreadsheetOptions.ForOnePagePerSheet();
            htmlViewOptions.SpreadsheetOptions.TextOverflowMode = TextOverflowMode.HideText;
            htmlViewOptions.SpreadsheetOptions.RenderHeadings = true;

            htmlViewOptions.ExcludeFonts = false;

            return htmlViewOptions;
        }

        public string GetPageContent(int pageNumber)
        {
            viewer.View(htmlViewOptions, pageNumber);
            stream.Position = 0;
            using (StreamReader reader = new StreamReader(stream))
            {
                string htmlContent = reader.ReadToEnd();
                stream.Dispose();
                return htmlContent;
            }
        }

        public void Dispose()
        {
            viewer.Dispose();
        }
    }
}

I’m used GroupDocs.Viewer to latest version (25.03).

After a quick investigate on my side, i think the problem still provide by the css on the span which contains the balise.

Original css :
image.png (3.7 KB)

My modified css for picture corresponding to Excel file
image.png (3.7 KB)

I have test the solution with .Net Framework 4.7.2 and .Net 8 version.

Thanks by advanced

@B.Leveille

It seems you are experiencing issues with rendering an Excel file that contains an embedded picture in a cell using the GroupDocs.Viewer library. This can sometimes be related to how the CSS is applied to the HTML elements generated during the rendering process.

Here are a few suggestions to troubleshoot and potentially resolve the issue:

  1. Check CSS Styles: Since you mentioned that the problem might be related to the CSS applied to the <img> tag, ensure that the styles are correctly defined. You can modify the CSS to ensure that the image is displayed properly without affecting the layout.

  2. Use Embedded Resources: When rendering the Excel file, make sure you are using the HtmlViewOptions.ForEmbeddedResources method. This will help in embedding all necessary resources, including images, directly into the HTML output. Here’s a snippet of how you can implement this:

    var viewOptions = HtmlViewOptions.ForEmbeddedResources("output.html");
    viewer.View(viewOptions);
    
  3. Adjust Spreadsheet Options: You can also explore the SpreadsheetOptions to control how the content is rendered. For example, you can set the TextOverflowMode to manage how text and images are displayed within the cells.

  4. Update to Latest Version: Ensure that you are using the latest version of the GroupDocs.Viewer library, as updates often include bug fixes and improvements related to rendering issues.

  5. Review Documentation: For more detailed information on rendering Excel files and handling embedded resources, refer to the official documentation on rendering spreadsheets. This can provide insights into specific options and configurations that might help with your issue.

If the problem persists after trying these suggestions, consider sharing the specific CSS modifications you made and any additional details about the rendering behavior you are observing. This information can help in diagnosing the issue further.

Feel free to reach out if you need more assistance!

Sources:
[1]: Render Excel and Apple Numbers spreadsheets as HTML, PDF, and image files

Hi @B.Leveille

Thanks for the input document and source code, we were able to reproduce the issue and obtained the same results as on your screeenshot. Our developers already started to work on it, this issue is logged in our bug tracking system as VIEWERNET-5315. We will notify you when will be some news on it.

Thanks and sorry for the inconvenience.

With best regards,
Denis Gvardionov