How to put a Spire.Xls.Collections.PicturesCollection into a string builder in c#?

443 Views Asked by At

So what I'm trying todo is get these pictures and put them into the string builder.

        StringBuilder sb = new StringBuilder();
        Spire.Xls.Workbook workbook = new Spire.Xls.Workbook();
        workbook.LoadFromFile(Path.Combine(path, file));
        Spire.Xls.Worksheet sheet = workbook.Worksheets[0];
        Spire.Xls.Collections.PicturesCollection pictures = sheet.Pictures;
        for (i = 0; i < pictures.Count; i++)
        {
            sb.Append(@"<img src="+pictures[i]+ " />");
        }
1

There are 1 best solutions below

3
Dheeraj Malik On

Try the following code:

StringBuilder sb = new StringBuilder();
Spire.Xls.Workbook workbook = new Workbook();
workbook.LoadFromFile(Path.Combine(path, file));
Spire.Xls.Worksheet sheet = workbook.Worksheets[0];
Spire.Xls.Collections.PicturesCollection pictures = sheet.Pictures;
for (int i = 0; i < pictures.Count; i++)
{
    string image_Path = "image" + (i + 1).ToString() + ".png";
    pictures[i].Picture.Save(image_Path, System.Drawing.Imaging.ImageFormat.Png);
    sb.Append(@"<img src=" + image_Path + "/>");
}