We want to open an existing Excel file with a lot of images, change the image resolution and save it to a new file.
I have been playing around with settings like DpiForReadingImages and DpiForImages but no luck.
Any ideas?
procedure ChangeDPI(const fileName: string; const dpi: integer);
var
xls: TXlsFile;
i: Integer;
imgType: TXlsImgType;
imgData: ByteArray;
begin
xls := TXlsFile.Create(fileName, true);
try
for i := 1 to xls.ImageCount do
begin
imgData := xls.GetImage(i, imgType);
imgData := ConvertDpi(imgData, dpi);
xls.SetImage(i, imgData);
end;
xls.Save(filename)
finally
xls.Free;
end;
end;
Thanks Adrian, this helps a lot!