It seems we can use either TAdvGridWorkbook or TAdvStringGrid when importing data using TAdvGridExcelIO.
When one is assigned the other is set to nil. All seems good.
So the question is what advantages/disavantages are there to using each?
Sorry, if this should be in the grid section, but it does seem somewhat specific to Flexcel.
An AdvGridWorkbook is just a collection of AdvStringGrids with a sheet bar at the bottom:
So what to use really depends in your use case. If you want a single sheet (or will manage multiple sheets on your own with your own controls), use an AdvStringGrid. If you want to import all the sheets at once, use a TAdvGridWorkbook
@adrian Thanks. Makes sense.
So I have been using the simple grid and my own drop-down combobox. The workbook variant is visually much nicer.
The underlying issue I was wondering was whether they handled memory differently when actually displaying the full cell properties
I am trying to use the grid to preview some BIG files where the color (background and font) is actually the important bit. The file I am looking at right now (Excel 97-2003 format) is nearly 30MB, approximately 25 sheets and upwards of 250 columns in some. In Excel the memory usage with the file loaded goes to about 200-230MB, but not too bad.
I can load it in the AdvStringGrid with cell properties option turned off. Memory usage goes up to about 160MB during loading and then drops back when the sheet is displayed.
When I turn on the cell properties option (as I need), loading the file and preparing for display takes a quite a long time, and you can watch memory usage climb and climb till it hits about 1.7GB, and the program reports out of memory..
From your description it sound like I am not going to solve main main issue simply using the built in functionality. I may have to see about whether I can use the virtual methods and all of the cell rendering myself. But I don't have time for that right now. I also think it is probably a question for one of the other sections in the TMS forum
If you just want to display the file, you can try with TFlexCelPreviewer. It will use much less memory and have better formatting. But it is a read-only viewer (you can't edit), and it displays the file the same as the Excel print-preview (by pages, not as a grid, but you can display the grid and grid headers).
You can try the example here:
It should use much less memory.
Finally, this is not really supported anymore, but if there will be only light editing (just changing cell values or no editing, just displaying), you can give TFlexCelGrid a try. It displays the file like a grid (not in pages like TFlexCelPreviewer) and has very limited editing capabilities (it is best if only used read-only). TFlexCelPreviewer is a deprecated component from FlexCel 3, but it works, and can use the latest FlexCel 7 engine internally. It is something I would not recommend (FlexCel 3 is not maintained anymore), but if you are having memory problems it can be a solution. At least until we develop a new FlexCel-7 FlexCelGrid.
If you want to try the FlexCelGrid, you can try the exe demo here and look at the memory used:
@adrian . Thanks. That does give me a few more things to try.
My use case here is purely read-only. Absolutely no editing required and in fact would be a bad thing... :-) Not sure if whole page preview is the way as it might be desired to move around the sheet.
Anyway a few things for me to play with.
Thanks once again.
OK. The demo in the zip file does work and I can view the file and navigate the grids, and the memory usage is only around 120MB (same as Excel). So, if I can reproduce that it will answer my immediate needs.
Only thing now is that I have to work out where that control is that presumably was used to build the demo. Can't find any obvious trace of it in the source...
The control is from FlexCel 3. It used to be in our website up to a couple of days ago, but we just removed the download from the registered users page because too many people were confused and downloaded the wrong version.
But if you think this is can be a solution (as said, sadly not much support on that since it is a very old component), I can email you a version of FlexCel 3 so you can try it. You need to install both FlexCel 7 and 3, as explained here: Migrating From FlexCel 3 | FlexCel Studio for VCL and FireMonkey documentation
And then what the exe I sent is one of the FlexCel 3 demos. You just need to replace the XlsAdapter by a XlsxAdapter (also as explained in the migration guide I posted above).
@adrian That would be really useful. I don't envision needing it for long, and will not be asking for any support beyond access to the download. You have my email address from the Excel files I sent yesterday.
[If later on there is anything I can do towards helping with creating a Flexcel7 version, which you said might be in the future, please let me know]