#1 2014-06-04 15:10:53

chris0086
Member
Registered: 2014-06-04
Posts: 2

Delphi draw a table from a stringgrid

Hello at all,
i use the synpdf engine and for the first test it working very well.
But now is have a problem and find no way out.
i used the example code to generate a sheet:
http://blog.synopse.info/post/2010/06/3 … -from-code

Now i want to draw my Stringgrid into the pdf.
The first contains the headers.
The stringrid contain rows and cols that are dynamical created.
so at first I tried to create columns and the columnheaders

var
Text: array of SynUnicode;
begin
     setlength(Text,x);
     cx1:=0;
     cx2:=20;
     y:= pred(MWGrid.RowCount); //erste Zeile enthält Beschreibung
     x:= pred(MWGrid.ColCount); //erste Spalte = Testschritte
for i:= 0 to x do
    begin
         text[i]:= MWGrid.Cells[i,0];
         AddColumn(cx1,cx2,caLeft,false);
         cx1:= cx1+20;
         cx2:=cx2+20;
    end;
    AddColumnHeaders(Text,true,true);

but the programm freezes.
If I comment "AddColumnHeaders(Text,true,true);" out then the sheet will be displayed but the columns have no caption.

In the second step i have to fill the rows with my data...

Is there anyone who can help me with this problem?

Kind regards
Christian

Offline

#2 2014-06-04 22:56:15

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: Delphi draw a table from a stringgrid

try

for i := 0 to x-1 do

as requested by any Delphi dynamic array.

Offline

#3 2014-06-05 12:44:53

chris0086
Member
Registered: 2014-06-04
Posts: 2

Re: Delphi draw a table from a stringgrid

I think this is not the problem also if i replace x with 2 it dont work.
How is the function addcolumnHeaders be used?

Offline

#4 2014-06-06 08:21:16

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: Delphi draw a table from a stringgrid

As written in the method doc, the number of columns and the number of items in the addCOlumnHeaders() must match.

Offline

Board footer

Powered by FluxBB