Page 1 of 1

AccessViolation in TXLSDrawing.InsertImage

Posted: Fri Apr 01, 2016 12:37 pm
by d3nton
XlsReadWrite throws an Accessviolation in TXLSDrawing.InsertImage if AFilename: AxUCString leads to file which is not an image or if the file is an image but has a wrong extension (e.g. renamed .png to .txt)
Could you please handle this exception (maybe allow renamed images / check if image is assigned etc.. and/or throw a meaningfull exception.).
Thank you for your help.

Re: AccessViolation in TXLSDrawing.InsertImage

Posted: Mon Apr 04, 2016 7:25 am
by larsa
Hello

Will fix this in the next update.

Re: AccessViolation in TXLSDrawing.InsertImage

Posted: Tue Aug 02, 2016 8:20 am
by d3nton
Hello!

Thank you for the fix.

In the current version I still receive a similar problem if I use the InsertImage function with a bmp image which should be included in a xls file:
The function call FGrManager.Images.LoadFromFile(AFilename); in the InsertImage function changes the bmp file to png and also changes the path of the file.
This leads to s EFOpenError exception in the next line:
DoInsertImage(Image,Round(Image.Width * AScale),Round(Image.Heigh * AScale),ACol,ARow,AColOffset,ARowOffset);
since the path with the renamed extension is not found.

Re: AccessViolation in TXLSDrawing.InsertImage

Posted: Wed Aug 03, 2016 9:26 am
by larsa
Hello

I can't reproduce this

Which Delphi do you use?

Re: AccessViolation in TXLSDrawing.InsertImage

Posted: Thu Aug 04, 2016 7:27 am
by d3nton
Hi!

I use Delphi 10.1 Berlin.
Did you export to an xls file? It works for xlsx files but not for xls files.

Re: AccessViolation in TXLSDrawing.InsertImage

Posted: Fri Aug 05, 2016 8:03 am
by larsa
Hello

Yes, I have tested with XLS files. It still works fine here.

Re: AccessViolation in TXLSDrawing.InsertImage

Posted: Fri Aug 05, 2016 1:34 pm
by d3nton
You just need a bmp file (e.g. test.bmp) and use the example below in order to get an EAccessViolation or an error dialog 'Cannot open... text.png':

Code: Select all

var
  lExcelFile : TXLSReadWriteII5;

begin
   lExcelFile :=  TXLSReadWriteII5.Create(nil);
   lExcelFile.Filename := 'D:\testfile.xls';
   lExcelfile.Version := xvExcel97;
   lExcelFile.Add;
   lExcelFile[0].Drawing.InsertImage('D:\test.bmp', 1,1, 0, 0, 1);
   lExcelfile.Write;
   FreeAndNil(lExcelFile);
end;

Re: AccessViolation in TXLSDrawing.InsertImage

Posted: Wed Aug 10, 2016 8:31 am
by larsa
Hello

Still no luck. Your code works fine.