TFlexCelImport.PrintScale

Hello I am having trouble getting the TFlexCelImport.PrintScale to actually change the print size even when i set PrintToFit to false.


begin
  FirstPage:=1;
  LastPage:=-1;
  PrintRange.Left:=1;
  PrintRange.Top:=1;
  PrintRange.Right:=Data.MaxPrintableCol;
  PrintRange.Bottom:=Data.MaxPrintableRow;

   FlexCelImport.printtofit:=false;
  FlexCelImport.printscale:= 300;

  for i:= 1 to FlexCelImport.RangeCount do
  begin



Maybe I am using it incorrectly but please advise.

Thanks



 

Hi,

Sorry, there is a bug in the code. I am in a business trip right now so I can't send a fix, but we will be publishing a new version with this fixed as soon as I get back home on friday.

Hello Adrian

Any news when you will release a bug fix please?

Thanks

Hi,

I am doing the build today, you can expect it between today and tomorrow.
It was going to be released some time ago, but with the new release of XE2, it made sense to wait so we wouldn't had 2 updates in a week. I just got the final xe2 yesterday (I had the RTM before that), so I am installing it today and with luck releasing it as soon as it is done and tests pass.

Flexcel 3.5 has beern released. It includes the bugfiexes here, as well as xe2 support (both 32 and 64 bits)

Thanks Adrian,
I am still having a problem with switching to landscape, maybe you can advise...


if printersettings.radiogroup1.itemindex = 1 then
   //Landscape
   FlexCelImport.PrintOptions := FlexCelImport.PrintOptions and not fpo_nopls and (not fpo_Orientation)
  else
   //Portrait
   FlexCelImport.PrintOptions := FlexCelImport.PrintOptions and not fpo_nopls or (fpo_Orientation);

 //page scale margins etc.
 if printersettings.FTPButton.down = true then
  begin
  FlexCelImport.printtofit:=true;
 // FlexCelImport.printscale:=trunc(printersettings.scale.Columns[0].selectedvalue);

  end else
  begin
  FlexCelImport.printtofit:=false;
  FlexCelImport.printscale:= 100;

  end;



Thank you

I don't see any problem with this code here?   I have tried and it correctly sets the page in landscape when the page checkbox is checked.

Can you review your hard disk and verify you have no old dcus/bpls hanging around?  We changed the destination folder in this new version to adapt to the new XE2 settings, so you need to make sure to uninstall the old version, and completely delete the FlexCel folder before installing the new one. 

I'd love to attach my test case here, but I can't find an "attach" button...

But is is mostly what you wrote.  The form has 1 button, 2 checkboxes, a flexcelimport and an xlsadapter. Code is as follows:

unit Unit8;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics,
  Controls, Forms, Dialogs, StdCtrls, ExtCtrls,
  UExcelAdapter, XLSAdapter, UFlexCelImport, ActiveX, UFlxMessages;

type
  TForm8 = class(TForm)
    Button1: TButton;
    FlexCelImport: TFlexCelImport;
    XLSAdapter1: TXLSAdapter;
    cbLandscape: TCheckBox;
    cbPrintToFit: TCheckBox;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form8: TForm8;

implementation

{$R *.dfm}

procedure TForm8.Button1Click(Sender: TObject);
var
  FileName : string;
begin
  FlexCelImport.NewFile(1);
  FlexCelImport.CellValue[1,1] := 1;

  if cbLandscape.Checked then
   //Landscape
   FlexCelImport.PrintOptions := FlexCelImport.PrintOptions and not fpo_nopls and (not fpo_Orientation)
  else
   //Portrait
   FlexCelImport.PrintOptions := FlexCelImport.PrintOptions and not fpo_nopls or (fpo_Orientation);

 //page scale margins etc.
 if cbPrintToFit.Checked then
  begin
  FlexCelImport.printtofit:=true;
 // FlexCelImport.printscale:=trunc(printersettings.scale.Columns[0].selectedvalue);

  end else
  begin
  FlexCelImport.printtofit:=false;
  FlexCelImport.printscale:= 100;

  end;

  FileName := IncludeTrailingPathDelimiter(GetEnvironmentVariable('TEMP')) + 'test.xls';
  FlexCelImport.Save(FileName);

end;

end.


If you want email me and I can send you a zip with the example. I tested the 4 combinations here and they all work fine. Do you have anything different in your setup?


To get my code to work i have changed it to this...



if printersettings.radiogroup1.itemindex = 1 then

   //Landscape

  // FlexCelImport.PrintOptions := FlexCelImport.PrintOptions and not fpo_nopls and (not fpo_Orientation) ;

    Printer.Orientation:=poLandscape

  else

   //Portrait

  // FlexCelImport.PrintOptions := FlexCelImport.PrintOptions and not fpo_nopls or (fpo_Orientation);

  Printer.Orientation:=poPortrait;


Oh, you were speaking about printing.  The FlexCelImport.PrintOptions option is just to set that bit in the xls file, so when you print it form Excel it will be landscape/portrait. But when printing with FlexCelGrid, we prefer not to change the seetings in the global Printer object, so yes, you need to change Printer.Orientation directly.