We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

LightCellsDataProvider add image


I’m evaluating aspose.cell product. We have to have abilty to generate huge excel file on the fly. I was looking into LightCellsDataProvider as an option and it looks great for us. But, the main thing I do not get is how to change the worksheet options.

For example, I try to add an image to the cell inside StartCell method. Doing it like a following:

_currentSheet.Pictures.Add(_row, _column, “aspose.jpg”, 100, 100);

My save method looks like a following:

var workbook = new Workbook();
var saveOptions = new OoxmlSaveOptions(SaveFormat.Xlsx)
LightCellsDataProvider = new MyImplementation();

//if i call add image method here - it works fine
workbook.Save(output, saveOptions);
//if add image called after this like of code - it stops working

So, do I have some options how to add an image to the cell?


Thanks for providing us details.

Well, Aspose.Cells provides the LightCells APIs which is mainly designed to write or read cell’s data one by one without building a complete data model block into memory. I suspect it might not be feasible for adding other objects or inserting binary data into cells. So, I think you may not add images in lightweight mode and you have to insert the pictures in normal mode.

We will further evaluate/check with the concerned developer from product team and get back to you with more details.

Thank you.


Thanks for using Aspose.Cells.

Just as Amjad has said, LightCells APIs are mainly for creating large cells data mode into the destination directly without saving it in memory. For other objects such as Shapes, Pictures, Conditional formatting, …etc. all should be created before saving. You should add images into one workbook as what should do in normal mode, then still use LightCellsDataProvider to add cells in save progress.

So, I will be unable to build some excel report with 10 000 images without keeping entire document on the host server either in the ram or on disk (MemorySetting.MemoryPreference if I understand correctly this setting).

Maybe you have some ideas how could I achieve this? Because all other looks cool to me, the only problem with a big number of images which I would not like to keep in ram or somewhere else.

I was also trying to insert image to the cell like html with image set as data-uri. But it does not work either.

was using code like cell.HtmlValue = “”;


Well, I am afraid, specifying HTML string (to display image from source) cannot work in LightCells APIs either. For images, we have to gather all image data into one pool and index them before rendering it to the resultant file, so we cannot support to add and output images while saving the workbook in lightweight mode. As you got to insert thousands of images into the worksheet, well, it also depends on what kind of images you are inserting into the spreadsheet. If all the images are of huge size, I am afraid, there is no better way to cope with memory issue.

Also, the MemoryPreference option would be same with LightCells mode, this option is mainly added for the cells data model, not for other objects like images. For those images, the option will give you no better results either.

Thank you.

Hi Amjad,

thank you for your replies.

Maybe you aware about converting html to excel format? From this thread as far as I understand aspose does not do any processing of tags but delegates is to excel ? so if I will provide html stream will it convert it to the office format on the fly?

of maybe you know a way how could I not to consume too much of ram when try to build file with a lot of images inside



Well, as I told you earlier, when specifying HTML string for images, still we need to parse, set indexing and output images accordingly, so it would not work in LightCells APIs. You got to do image insertion in normal mode. Anyways, I will still check with the concerned developer from product team and may get back to you with more details.

Thank you.