mini-software / MiniExcel

Fast, Low-Memory, Easy Excel .NET helper to import/export/template spreadsheet (support Linux, Mac)
https://www.nuget.org/packages/MiniExcel/
Apache License 2.0
2.81k stars 344 forks source link

Export image to custom template #604

Open leandrobattochio opened 6 months ago

leandrobattochio commented 6 months ago

So I have a custom template but I can't add images. All the rows are being added fine but when it's supposed to have an image, the cell shows only "System.Byte[]".

How can I add an image using SaveAsByTemplateAsync ?

piotr-nawrot-golba-music commented 5 months ago

@leandrobattochio

Thank you for bringing up this issue. I've encountered a similar problem when using the library. Specifically, when setting

var c = new OpenXmlConfiguration
{
    EnableConvertByteArray = true
};

to insert the images to the template, I encountered an exception in the UpdateDimensionAndGetRowsInfo method.

After investigating this issue, I suspect that there might be a limitation in the current library's ability to handle byte arrays in the templates. As a temporary workaround, I've used the ClosedXML library to insert my images into the templates first, and then I've used MiniExcel to insert the rest of the values. This approach might not be ideal, but it may serve to unblock your progress until this issue is addressed by the library authors. It would be a great feature enhancement if the library could support the inclusion of images from byte arrays inside templates directly. Looking forward to this enhancement.