Go Delphi Export Settings operation for Excel

Source: Internet
Author: User

Set page margins:

exlapp.activesheet.pagesetup.topmargin:=1.5/0.035;

exlapp.activesheet.pagesetup.bottommargin:=1.5/0.035;

exlapp.activesheet.pagesetup.leftmargin:=1/0.035;

exlapp.activesheet.pagesetup.rightmargin:=1/0.035;

exlapp.activesheet.pagesetup.headermargin:=0.5/0.035;

exlapp.activesheet.pagesetup.footermargin:=0.5/0.035;

Set Page Alignment

Exlapp.activesheet.pagesetup.centerhorizontally:=true; Horizontal center of page

ExlApp.ActiveSheet.PageSetup.CenterVertically: =true; Vertical center of page

Set the overall font format

exlapp.cells.font.name:= ' song body '; Font

exlapp.cells.font.size:=12; Size

exlapp.cells.rowheight:=16; Row height

exlapp.cells.verticalalignment:=2; Vertical alignment: Centered

End {Creatrepsheet}

Procedure setaddmess (h_mess1,h_mess2,h_mess3,f_mess1,f_mess2,f_mess3:string);

User-defined header, footer (ie: page title, page number)

Begin

Exlapp.activesheet.pagesetup.leftheader:=h_mess1;

Exlapp.activesheet.pagesetup.centerheader:=h_mess2;

EXLAPP.ACTIVESHEET.PAGESETUP.RIGHTHEADER:=H_MESS3;

End {setaddmess}

Procedure Setrepbody (x,ch:integer;cw:double;cf:string);

Set the overall column data format

Begin

EXLAPP.ACTIVESHEET.COLUMNS[X]. COLUMNWIDTH:=CW; Column width

EXLAPP.ACTIVESHEET.COLUMNS[X]. NUMBERFORMAT:=CF; Cell data format

EXLAPP.ACTIVESHEET.COLUMNS[X]. Horizontalalignment:=ch; Horizontal direction Alignment

End {Setrepbody}

Procedure Creattitle (Titlename:string;y:integer);

{Set Caption}

Var

repspace:string;

Begin

Cellmerge (1,1,1,y);

Exlapp.cells (): =titlename;

Repspace:= ' A1 ' + ': ' +getreprange (1,y);

Exlapp.range[repspace]. Select;

ExlApp.Selection.NumberFormat: = ' g/universal format ';

exlapp.selection.font.size:=22;

exlapp.selection.font.name:= ' blackbody ';

Exlapp.selection.font.bold:=true;

exlapp.selection.horizontalalignment:=3; Horizontal alignment: Centered

EXLAPP.ROWS[1]. rowheight:=28;

End {Rephead}

Procedure Creatsubhead (Subtitle:array of String);

{Set regular child header}

Var

I,j:integer;

Begin

j:=0;

For I:=low (SubTitle) to High (SubTitle) do

Begin

INC (j);

Exlapp.cells (2,J): =subtitle[i];

End

End {Creatrephead}

Procedure Subheadformat (Y,r:integer);

{Set Child header format}

Var

repspace:string;

N:integer;

Begin

Repspace:= ' A2 ' + ': ' +getreprange (1+r,y);

Exlapp.range[repspace]. Select;

ExlApp.Selection.NumberFormat: = ' g/universal format ';

exlapp.selection.horizontalalignment:=3; Table Header Horizontal alignment: Centered

Exlapp.selection.font.bold:=true;

For N:=1 to R do

Begin

Exlapp.rows[1+n]. rowheight:=18;

Setrepline (1+n,y);

End {for}

End {Subheadformat}

Procedure Dtsubheadgs (X,y,r:integer);

{Set dynamic child header format}

Var

repspace:string;

N:integer;

Begin

Repspace:=getreprange (x,1) + ': ' +getreprange (x+r-1,y);

Exlapp.range[repspace]. Select;

ExlApp.Selection.NumberFormat: = ' g/universal format ';

exlapp.selection.horizontalalignment:=3; Table Header Horizontal alignment: Centered

Exlapp.selection.font.bold:=true;

For n:=0 to R-1 do

Begin

Exlapp.rows[x+n]. rowheight:=18;

Setrepline (X+n,y);

End {for}

End {Dtsubheadgs}

Procedure WriteData (repdata:string; x,y,flag:integer); Write Data

{Write Data}

Begin

If Flag=1 Then

Exlapp.cells (x, y): =strtodate (Repdata)

Else

Exlapp.cells (x, y): =repdata;

End {Writedate}

Procedure Reppagebreak (X,y,r:integer); X: Number of rows at pagination, Y: Number of columns, R: Total number of rows in child header

paging, duplicating headers

Var

repspace:string;

N:integer;

Begin

EXLAPP.ACTIVESHEET.ROWS[X]. PageBreak: = 1;

Repspace:= ' A1 ' + ': ' +getreprange (r+1,y);

Exlapp.activesheet.range[repspace]. Copy;

repspace:= ' A ' +inttostr (x);

Exlapp.activesheet.range[repspace]. PasteSpecial;

EXLAPP.ROWS[X]. rowheight:=28;

For n:=2 to R do

Exlapp.rows[x+n]. rowheight:=18;

End {Reppagebreak}

Procedure Repsaveas (filename:string);

{Save as *.xls file}

Begin

Try

Exlbook.saveas (FileName);

Except

Messagedlg (' cannot access the file, please close Microsoft Excel before running this program! ', Mterror, [Mbok], 0;

End

End {Repsaveas}

Procedure Repprivew (filename:string);

Preview

Begin

Repcreat;

Exlapp.visible: =true;

Try

ExlApp.workBooks.Open (FileName);

EXLAPP.WORKBOOKS[1]. WORKSHEETS[1]. PrintPreview;

Finally

Exlapp.quit;

exlapp:=unassigned;

Exlapp:= ";

End {Try}

End {Repprivew}

Procedure Repquit;

{Exit Excel}

Begin

Exlbook.close;

Exlapp.quit; Exit Excel Application

exlapp:=unassigned; Releasing Variant variables

End {Repquit}

Procedure Repdestroy;

{Abnormal exit from Excel}

Begin

If not Varisempty (Exlapp) Then

Repquit;

End {Repdestroy}

End.

Go Delphi Export Settings operation for Excel

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.