Hi
Hi,
While indeed defining a TVirtualDataTable/TVirtualDataTableState is indeed the "right" solution, in this case it might be a little overkill.
If this is a one-off thing, and the memos don't have millions of lines, the simplest way is to copy those strings into a TArray<SomeRecordWithASingleStringField> and then run the report on that. Something like this:
type
TData = record
Data: string;
end;
procedure DoReport(const memo1: TMemo);
var
m: TArray<TData>;
fr : TFlexCelReport;
i: integer;
begin
SetLength(m, memo1.Lines.Count);
for i := Low(m) to High(m) do m.Data := memo1.Lines;
fr := TFlexCelReport.Create(true);
try
fr.AddTable<TData>('memo1', m);
fr.Run('template.xlsx', 'result.xlsx');
finally
fr.Free;
end;
end;
In the template, you would write <#Memo1.Data> inside a Memo1 range.
But well, while this is the fastest to implement, this solution does have the drawback that the data on the memo is copied into the TArray<TData>
For a more generic solution, indeed defining a VirtualDataTable/VirtualDataTableState is the way to go. Doing it is not too difficult: You need to descend 2 classes from TVirtualDataTable and TVirtualDataTableState, and implement the abstract methods. This will give you a "minimum" DataTable which you can use but which lacks advanced stuff like master detail or the ability to filter the dataset. There is no doc in vcl, but you can read the FlexCel.NET doc in the topic which is similar:
http://www.tmssoftware.biz/flexcel/docs/net/UsingFlexCelReports.pdf
(look at the appendix II). But the simplest is to just ctrl-click in TVirtualDataTable and ctrl-click again to get to the definition: every method is documented. I personally prefer to read the docs directly in the sources, but if you prefer, you can press F1 to get help in TVirtualDataTable/State or read it here:
http://www.tmssoftware.biz/flexcel/hlp/vcl/index.htm?FlexCel.Report.TVirtualDataTable.htm
http://www.tmssoftware.biz/flexcel/hlp/vcl/index.htm?FlexCel.Report.TVirtualDataTableState.htm
I have made a simple demo to show how to use a TVirtualDataSet in this case. You can just reuse the unit UStringListDataProvider in your app.
Get it here:
http://www.tmssoftware.biz/flexcel/samples/stringlisttable.zip
Hi Adrian