How to convert PageSetup-Properties to XLSReadWrite ?

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
OlafSt
Posts: 1
Joined: Thu Jul 18, 2019 8:16 am

How to convert PageSetup-Properties to XLSReadWrite ?

Post by OlafSt »

Hello Friends,

we're encountering a problem here and we're unable to solve this. Time is running up very fast so we do not have any mor time for further research. As the docs for XLSReadWrite are widely non-existent we used the sources to figure out... But this is enormously time consuming.

We have to convert following simple code to XLSReadWrite:

Code: Select all

procedure TAufToExcel2.SetupSheets(Ex: TExcelApplication);
var
   ColString: string;
   Sh: _Worksheet;
   ER: ExcelRange;
   SheetCount: integer;
   ColCount: Integer;
begin
     for SheetCount:= 1 to Ex.Sheets.Count do
     begin
          Sh:=Ex.Sheets.Item[SheetCount] as _WorkSheet;
          Sh.PageSetup.PrintTitleRows:='$1:$7';
          Sh.PageSetup.PrintTitleColumns:='';
          Sh.PageSetup.PrintArea:='';
          Sh.PageSetup.PrintGridlines:=false;
          Sh.PageSetup.LeftHeader:='';
          Sh.PageSetup.CenterHeader:='';
          Sh.PageSetup.RightHeader:='';
          Sh.PageSetup.LeftFooter:='';
          Sh.PageSetup.CenterFooter:='';
          Sh.PageSetup.RightFooter:='';
          Sh.PageSetup.LeftMargin:=Excel.Application.InchesToPoints(0.196850393700787, 0);
          Sh.PageSetup.RightMargin:=Excel.Application.InchesToPoints(0.196850393700787, 0);
          Sh.PageSetup.TopMargin:=Excel.Application.InchesToPoints(0.590551181102362, 0);
          Sh.PageSetup.BottomMargin:=Excel.Application.InchesToPoints(0.590551181102362, 0);
          Sh.PageSetup.HeaderMargin:=0.0;
          Sh.PageSetup.FooterMargin:=0.0;
          Sh.PageSetup.PrintHeadings:=false;
          Sh.PageSetup.PrintComments:=xlPrintNoComments;
          Sh.PageSetup.CenterHorizontally:=true;
          Sh.PageSetup.CenterVertically:=false;
          Sh.PageSetup.Orientation:=xlLandscape;
          Sh.PageSetup.Draft:=false;
          Sh.PageSetup.PaperSize:=xlPaperA4;
          Sh.PageSetup.FirstPageNumber:=0;
          Sh.PageSetup.Order:=xlDownThenOver;
          Sh.PageSetup.BlackAndWhite:=false;
          Sh.PageSetup.Zoom:=false;
          Sh.PageSetup.FitToPagesTall:=99;
          Sh.PageSetup.FitToPagesWide:=1;
          if SheetCount > 1 then
          begin
               for ColCount := 0 to FExcelCols.Count - 1 do
               begin
                    ColString:=Format('%s1', [GetExcelColChar(ColCount)]);
                    ER:=Sh.Range[ColString,ColString].EntireColumn;
                    ER.ColumnWidth:=FExcelCols[ColCount].ColWidth;
               end;
          end;
     end;
end;
However, we already fail in getting the count of Worksheets, as this property or function simply doesnt't exists or we cannot see the property/function due to a somewhat unlogical name - we have suspicion, that it may be the simple "Count"-Property. As mentioned before, Documentation is of no help.

Anyone out there who can point us into the right direction ?

Many, many thanks for any help !

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

Re: How to convert PageSetup-Properties to XLSReadWrite ?

Post by larsa »

Hello

Sorry for the late answer, but I have been on vacation.

You will find most of the properties in the XLS[0].PrintSettings object.
Lars Arvidsson, Axolot Data
Post Reply