Aspose.Cells Html to Excel conversion not showing images

Hi Ahsan Iqbal,
I tried the sample code which you have provided, it did not work. I am not able to see the images in output excel file.
Thank you.

@kumar.penigalapati,
Can you debug your code to find whether getting image stream? Getting image stream is in the StreamProvider47584 class.
You can change the method “InitStream(StreamProviderOptions options)” for getting image stream.

Hi Ahsan Iqbal,
yes i am getting the stream fine under StreamProvider47584 class InitStream method.
when i have 3 images in the html file i am getting all 3 streams fine.
but still i don’t see the images in excel output file.

@kumar.penigalapati,
Thanks for the feedback. We will share our feedback soon.

@kumar.penigalapati,

Please run the following code in your web application:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
ServicePointManager.SecurityProtocol |= (SecurityProtocolType)0x300;
ServicePointManager.SecurityProtocol |= (SecurityProtocolType)0xC00;

WebProxy proxy = new WebProxy(proxyUrl);
WebRequest request = WebRequest.Create("https://csmusdev.servicenowservices.com/10Things02a.pngx");
request.Proxy = proxy;
WebResponse response = request.GetResponse();
Bitmap.FromStream(response.GetResponseStream(), true).Save(filePath + "out.pngx");

Can you get the image?

Hi Amjad Sahi,
yes I am able to see the image fine.
out.zip (17.9 KB)

@kumar.penigalapati,
Thank you for sharing the feedback. We are analyzing it and will share our feedback soon.

@kumar.penigalapati,
Please run the following code in your web application:

        HtmlLoadOptions options = new HtmlLoadOptions();
        options.StreamProvider = new StreamProvider47584(proxyurl);
        Workbook wb = new Workbook(filePath + "HtmlPage2.html", options);                
        wb.Save(filePath + "Page_out.xlsx");


class StreamProvider47584 : IStreamProvider
{
    private string proxyUrl;
    public StreamProvider47584(string url)
    {
        this.proxyUrl = url;
    }

    void IStreamProvider.InitStream(StreamProviderOptions options)
    {
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
        ServicePointManager.SecurityProtocol |= (SecurityProtocolType)0x300;
        ServicePointManager.SecurityProtocol |= (SecurityProtocolType)0xC00;

        WebProxy proxy = new WebProxy(proxyUrl);
        WebRequest request = WebRequest.Create(options.DefaultPath);
        request.Proxy = proxy;
        WebResponse response = request.GetResponse();
        Stream srcStream = response.GetResponseStream();

        byte[] imageBytes = CopyStreamToByteArray(srcStream);
        options.Stream = new MemoryStream(imageBytes);           
    }

    void IStreamProvider.CloseStream(StreamProviderOptions options)
    {
        if (options != null && options.Stream != null)
        {
            options.Stream.Close();
        }
    }           
}

internal static byte[] CopyStreamToByteArray(Stream stream)
{
    int length = (int)stream.Length;
    byte[] data = null;
    if (length == 0)
    {
        if (stream.CanSeek)
        {
            stream.Position = 0;
        }
        data = new byte[4096];
        MemoryStream dest = new MemoryStream();
        while (true)
        {
            int size = stream.Read(data, 0, data.Length);
            if (size > 0)
            {
                dest.Write(data, 0, size);
            }
            else
            {
                break;
            }
        }
        return dest.ToArray();
    }
    else
    {
        data = new byte[length];
        if (stream.CanSeek)
        {
            stream.Position = 0;
        }
        stream.Read(data, 0, length);
    }

    return data;
}

Can you try it and let us know your feedback.

@kumar.penigalapati,

Moreover, If you still could not get the image, please check the imageBytes of every image stream and provide us more details on it, we will check it soon.

Hi Amjad Sahi,
with the example you provided i was getting an error at the line
int length = (int)stream.Length;

but i have modified it little but and after that it works fine, i am able to see the images fine.
but the only issue is they are not aligned correctly, they are on top of each other.
please see the attached code.WebApplication7.zip (8.3 MB)

@kumar.penigalapati,
Please spare us little time to investigate it and share our feedback.

Hi Ahsan Iqbal,
Any update ? we have a release approaching in a week, we would like to get this thing working as soon as possible.
Appreciate your efforts if you can quickly resolve this.
Thank you.

@kumar.penigalapati,
We are gathering information about this issue and will share our feedback as soon as available for sharing.

@kumar.penigalapati,
We are fixing it, we will provide the fix version before November 18, 2020.

ok Thank you Ahsan Iqbal

@kumar.penigalapati,
We have fixed the image position issue, please download Aspose.Cells for .Net 20.11.1 and let us know your feedback.

Aspose.Cells20.11.1 For .Net2_AuthenticodeSigned.Zip (5.4 MB)
Aspose.Cells20.11.1 For .Net4.0.Zip (5.4 MB)

Hi Ahsan Iqbal,
The fix seems to be working fine, but we are still seeing the images being over lapping the text.
please see the attachments.
Thanks.

can you please Create a Nuget package with what you have right now ? so we can move forward with our release, and may be fix those issues later ?
Thank you.

@kumar.penigalapati,
It seems that you forgot to attach the files. Please share your attachments for our reference.

yes :slight_smile: please see it now.
2020-11-19_8-33-13.zip (65.7 KB)

@kumar.penigalapati,
You may share your latest test application along with template files (if any) as well which is updated according to all the above suggestions for our final review and reproducing this issue here.

Regarding the NuGet package, this hot fix will be available through NuGet package manager after three weeks time when next release will be published.