FlexCel to TTMSFMXGrid

Hi


excel files are correctly imported to the FlexCelPreviewer using the followin code inluding ChekBoxes, Bitmaps etc

function TForm6.OpenFile(const aURL: string): boolean;
var
 xls       : TXlsFile;
 ImgExport : TFlexCelImgExport;
begin
 Result := true;
 try
   xls := TXlsFile.Create(aURL, true);
   ImgExport := TFlexCelImgExport.Create(xls, true);
   FlexCelPreviewer1.Document := ImgExport;
   FlexCelPreviewer1.InvalidatePreview;
   TMSFMXGridExcelImport1.Import(ImgExport.Workbook);
   // Next call throws the same access violation in FMX.Graphics
   // raise EBitmapLoadingFailed.Create(SBitmapLoadingFailed);
   TMSFMXGridExcelImport1.Import(aURL);
(
   ---------------------------
   Benachrichtigung ?ber Debugger-Exception
   ---------------------------
   Im Projekt FlexCellTest.exe ist eine Exception der Klasse EBitmapLoadingFailed mit der Meldung 'Laden des Bitmaps fehlgeschlagen.' aufgetreten.
   ---------------------------
   Anhalten   Fortsetzen   Hilfe   
   ---------------------------
)   
  except
    Result := false;
  end;
end;

But when I try to assign to TMSFMXGridExcelImport, it throws an exception, as soon there are images within the file. Code works without embedded bitmaps in the files.

J?rn

Hi,

Does this happen with any image? 
The most common cause for this is if the images in Excel are vectorial instead of bitmaps. (that is they are emf or wmf instead of pngs). wmf (Windows metafiles) and emf (enhanced windows metafiles) are file formats that only work in Windows (they are basically a bunch of GDI commands, like say "DrawRectangle, DrawString", etc). But as FMX is platform independent, we can't just load those images, even in Windows. FlexCelPreviewer can because it doesn't use FMX canvases/classes, and uses GDI+ directly when in Windows. But FlexCelPreviewer won't be able to show those images in OSX or other OS either.

Can you send me some example file to adrian@tmssoftware.com so I can confirm if your problem is related to having emf/wmf images in the file?

Thank you Adrian for the quik response.

We are using png/bmp files. I will send you two files.

Joern

Thanks for the files, I've got them. The access violation seems to be a different error, and happens when you merge cells in a grid where a cell already had an image. We are investigating it, but as a temporary workaround, if you unmerge the cells in A1 it should be able to open the file.


About the checkboxes, we currently export them but not import them into the grid. I don't remember the specifics and we will reevaluate if they can be imported, but I think that there was something preventing us from importing them into the grid. The FlexCelPreview component doesn't have this limitations because it has nothing to import or export, it just shows what is in the file. But when importing or exporting to the grid, we are limited by the things the grid can and can't do.

I'll let you know when I have more information.

When exporting the grid using TMSFMGridExcelExport. CheckBoxes and Bitmaps assigned to cells, are exported correctly. ComboBoxes and RadioButtons are stripped off.
I will try to unmerge the cells.

Thanks for your effort.

Jörn