Rows[liRow].PixelHeight don't work!

Questions and answers on how to use XLSReadWriteII 3/4/5.
Post Reply
mreinoldki
Posts: 6
Joined: Thu May 24, 2007 6:45 am

Rows[liRow].PixelHeight don't work!

Post by mreinoldki »

I'm using version 3.01.02 of XLSReadWriteII 3.0.

The code
lXLSReadWriteII21.Sheets[0].Rows[liRow].PixelHeight := 200;
don't have any effect. It doesn't work!


lXLSReadWriteII21.Sheets[0].Rows[liRow].Height := 400;
works...

Regards,

mrk
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Post by larsa »

Hello

I don't have any problems with PixelHeight.


Lars Arvidsson
mreinoldki
Posts: 6
Joined: Thu May 24, 2007 6:45 am

Post by mreinoldki »

Code: Select all

procedure TForm1.Button2Click(Sender: TObject);
var
  lXLSReadWriteII21: TXLSReadWriteII2;
  liCol: integer;
  liRow: integer;
  lsFilename: string;
begin
  lsFilename := 'c:\temp\XLSTest.xls';
  lXLSReadWriteII21 := TXLSReadWriteII2.Create(self);
  try
    lXLSReadWriteII21.Filename := lsFilename;

    for liRow := 0 to 10 do
    begin
      lXLSReadWriteII21.Sheets[0].Rows.AddIfNone(liRow);
      lXLSReadWriteII21.Sheets[0].Rows[liRow].PixelHeight := 200;               // don't work!
//      lXLSReadWriteII21.Sheets[0].Rows[liRow].Height := 200;                  - works
//      lXLSReadWriteII21.Sheets[0].Rows.SetRowHeight(liRow, liRow, 200);       - works
      for liCol := 0 to 10 do
      begin
        lXLSReadWriteII21.Sheets[0].Columns.AddIfNone(liCol, 1);
        lXLSReadWriteII21.Sheets[0].Columns[liCol].PixelWidth := 200;           // works
        lXLSReadWriteII21.Sheets[0].AsWideString[liCol, liRow] := IntToStr(liCol) + '/' + IntToStr(liRow);
      end;
    end;

    lXLSReadWriteII21.Write;
 finally
    FreeAndNil(lXLSReadWriteII21);
  end;
end;
What is wrong in this code?
PixelHeight don't have any effect!

Please, can you give me an example?

Regards,

mrk
mreinoldki
Posts: 6
Joined: Thu May 24, 2007 6:45 am

Post by mreinoldki »

What is wrong in this code?
Please, can you give me an example?
mreinoldki
Posts: 6
Joined: Thu May 24, 2007 6:45 am

Post by mreinoldki »

Hello Lars,

I modified your Source from

Code: Select all

procedure TXLSRow.SetPixelHeight(const Value: integer);
var
  F: TFont;
begin
  F := TFont.Create;
  try
    FFormats.Fonts[0].CopyToTFont(F);
    FHeight := -Round((Value / (F.Height / F.Size)) * 20);
  finally
    F.Free;
  end;
end;
to

Code: Select all

procedure TXLSRow.SetPixelHeight(const Value: integer);
var
  F: TFont;
begin
  F := TFont.Create;
  try
    FFormats.Fonts[0].CopyToTFont(F);
    FHeight := -Round((Value / (F.Height / F.Size)) * 20);

    SetHeight(FHeight);        //new!!!
  finally
    F.Free;
  end;
end;
and now it works fine for me.

Please let mit know if you plan to add this code to your next releases.

Regards,

mrk
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Post by larsa »

Hello

This was fixed in version 3.00.03, so you don't seems to have the latest version installed.


Lars Arvidsson
Post Reply