How read from Excel rows row by row with images with XLSRead

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
mrUlugbek
Posts: 2
Joined: Wed Aug 16, 2017 5:56 am

How read from Excel rows row by row with images with XLSRead

Post by mrUlugbek »

Hi All
I need help
How read from Excel rows row by row with images with XLSReadWriteII?
I have excel file with goods list with image how read and import to database?
Can you give sample?
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: How read from Excel rows row by row with images with XLSRead

Post by larsa »

Hello

Loop trough the Images object of the Drawing object and check the Row1 and Row2 properties of the images. Please study the Pictures sample for more details.
Lars Arvidsson, Axolot Data
mrUlugbek
Posts: 2
Joined: Wed Aug 16, 2017 5:56 am

Re: How read from Excel rows row by row with images with XLSRead

Post by mrUlugbek »

Can you make little bit source or example i found other example but comobj

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  ExcelObj:OleVariant;
  SheetObj:OleVariant;
  CellObj:OleVariant;
  i:integer;
  pict_count:integer;
  pict: TPicture;
begin
  ExcelObj := CreateOleObject('excel.application');
  ExcelObj.Application.DisplayAlerts:=False;
  ExcelObj.Workbooks.Open(ExtractFilePath(application.ExeName)+  'Book1.xlsx');
  SheetObj:=ExcelObj.Workbooks[1].Sheets[1];
  pict_count:=sheetObj.Pictures.Count;
  for i := 0 to pict_count-1 do begin
    CellObj:=SheetObj.Pictures[i+1].TopLeftCell;
   
    //for log
    Memo1.Lines.Add(format('[ %d , %d ]',[integer(CellObj.Row),integer(CellObj.Column)])) ;
   
    SheetObj.Pictures[i+1].select;
    SheetObj.Pictures[i+1].copy;

    if Clipboard.HasFormat(CF_PICTURE) then begin
      pict := TPicture.Create;
      try
        pict.Assign(Clipboard);
        pict.SaveToFile(format('%s',[SheetObj.Pictures[i+1].Name]));
        pict.Free; 
      except
      // Can't convert
      end;
    end;
  end;

  SheetObj:=unassigned;
  CellObj:=unassigned;
  ExcelObj.Quit;
  ExcelObj:=unassigned;
end;

But i want how do this by your lib?
Post Reply