Your idea with the format list: Certainly, but we don't have it - it is as simple as that. fpspreadsheet stores formats in the cells, not in a list (a temporary format list is created during reading and writing, but you don't know the format index of a given cell in the first place).
Yeah... i don't think i'm explaining it clear enough. (Is FFormattingStyles not a format-list at this point? Which you use to search for same formatting before assigning a style-index to a cell during writing?)
From the source:
{@@
Checks if the formatting style of a cell is in the list of manually added
FFormattingStyles and returns its index, or -1 if it isn't
@param AFormat Cell containing the formatting styles which are seeked in the FFormattingStyles array.
}
function TsCustomSpreadWriter.FindFormattingInList(AFormat: PCell): Integer;
Now with woVirtualMode your looping through VirtualRowCount and VirtualColCount so every cell is received (empty or not) via the NeedCellData. I'm just saying if we've got the possibility of also giving an AFormat (at that point) you could check if that style is already used (get the correct index from style-memory like FFormattingStyles is now). If so write that style-
index together with the cell to the sheet-stream. If it is not used, store it in memory (i.e. FFormattingStyles) for later reference and use that new
index for the cell. (The style.xml-stream could also be appended directly because we have the FColumnStyleList in memory).
That way every cell can have it's own formatting (if every cell has different formatting it would take memory but if lots of cells have the same formatting the memory requirement will be low, it's up to the user if he wants to apply lots of different styles).
That's just how i see it now...
Don't worry if i'm explaining this not clear enough.In that case i will see how the fpsopendocument.pas evolves and get back when i can be somewhat more concrete (with code-examples).
I'd vote for a major rewrite making cells to classes instead of records and trying to have least memory attached to cells.
Yeah... that was also my thought... Make the
properties of the TCell a sort of TList or something so when properties aren't used they don't take any space.
if you want to keep formatting with woVirtualMode you'll have to sacrifice some memory
I don't think so - I'll have to find a place within the writing process where the formatting information is completely known and an event handler can be hooked in.
That would almost always mean two passes or like i suggested above collecting the formatting information in NeedCellData and storing the
unique styles in memory (which should not take that much memory).
But is will not be possible to assign an arbitrary format to an arbitrary virtual cell.
... Except, maybe, for a header row.
That would be a shame because it would mean less control over the overall design of your sheets.
(and how about a footer row)
Not sure if you noticed my earlier post about the xlsxooxml.pas typo in <span> (so i include it here again):
2) I found that the files created with woVirtualMode are a few KB larger.
It seems that sheet1.xml are different for both methods.
I see in one sheet1.xml you do a <row r="19" spans="1:10000"> and in the other <row r="19" spans="1:100">
In xlsxooxml.pas you set it to Rowcount for woVirtualMode and to Colcount for [].
Typo ??? 