facebooktwittermenuarrow-up

GemBox Support Forum

Compress pictures in Excel files

Does the GemBox.Spreadsheet have a method to compress picture? I know it can accept Jpeg which is a lot smaller than most but I would like to know if there is the ‘Compress Pictures’ functionality that Excel has.

Hi Craig,

Yes, you can optimize the images by reducing their size with XlsxSaveOptions.ImageDpi property.
For example, try the following:

var workbook = ExcelFile.Load("input.xlsx");

var saveOptions = new XlsxSaveOptions();
saveOptions.ImageDpi = 220;

workbook.Save("output-with-compressed-images.xlsx", saveOptions);

Does this solve your issue?

Also just as an FYI, you can achieve this with output PDF as well, using the PdfSaveOptions.ImageDpi property.

Regards,
Mario

This resolved my issue. Thank you!