怎么通过Excel控制打印预览中打印纸张的大小和宽高(100分)

  • 主题发起人 主题发起人 jackalwin
  • 开始时间 开始时间
J

jackalwin

Unregistered / Unconfirmed
GUEST, unregistred user!
通过OLE创建个Excel对象
xlapp:variant;
...
怎样通过这个Excel对象控制打印预览中打印纸张的大小和宽高
 
with xlapp.ActiveSheet.PageSetup do
begin
PaperSize := xlPaperA3;//打印预览中的纸张设置就是页面设置,是否需要这种效果?
LeftMargin := xlapp.InchesToPoints(0.748031496062992);
RightMargin := xlapp.InchesToPoints(1.14173228346457);
TopMargin := xlapp.InchesToPoints(1.18110236220472);
BottomMargin := xlapp.InchesToPoints(0.984251968503937);
end;
 
正解。
刚才我测试的时候怎么都没有自定义纸张,设置xlPaperUser值的时候就会出错,不知道为什么
 
嗯 我也试过这种方法 不过也会出错
帮忙想想~
 
设置当然系统默认打印机支持的纸张大小,不会出错。我测试了。
 
编译未通过,报错:未经申报的标识符:xlPaperA3,我换了xlPaperA4也不行 是我需要添加什么单元么?
 
在uses中添加excel2000单元
 
添加不了啊 alt+F11 添加啊~?
迷糊了~
 
在您的单元文件的uses子句中添加!
 
是啊 我就在那添的
错误:file not found 'excel2000.dcu'
 
这个单元文件的源码应该在Delphi的安装目录/OCX/Servers下,dcu文件在/Imports下。如果只是想引用纸型你可以在你的单元文件中加上
const
xlPaper10x14 = $00000010;
xlPaper11x17 = $00000011;
xlPaperA3 = $00000008;
xlPaperA4 = $00000009;
xlPaperA4Small = $0000000A;
xlPaperA5 = $0000000B;
xlPaperB4 = $0000000C;
xlPaperB5 = $0000000D;
xlPaperCsheet = $00000018;
xlPaperDsheet = $00000019;
xlPaperEnvelope10 = $00000014;
xlPaperEnvelope11 = $00000015;
xlPaperEnvelope12 = $00000016;
xlPaperEnvelope14 = $00000017;
xlPaperEnvelope9 = $00000013;
xlPaperEnvelopeB4 = $00000021;
xlPaperEnvelopeB5 = $00000022;
xlPaperEnvelopeB6 = $00000023;
xlPaperEnvelopeC3 = $0000001D;
xlPaperEnvelopeC4 = $0000001E;
xlPaperEnvelopeC5 = $0000001C;
xlPaperEnvelopeC6 = $0000001F;
xlPaperEnvelopeC65 = $00000020;
xlPaperEnvelopeDL = $0000001B;
xlPaperEnvelopeItaly = $00000024;
xlPaperEnvelopeMonarch = $00000025;
xlPaperEnvelopePersonal = $00000026;
xlPaperEsheet = $0000001A;
xlPaperExecutive = $00000007;
xlPaperFanfoldLegalGerman = $00000029;
xlPaperFanfoldStdGerman = $00000028;
xlPaperFanfoldUS = $00000027;
xlPaperFolio = $0000000E;
xlPaperLedger = $00000004;
xlPaperLegal = $00000005;
xlPaperLetter = $00000001;
xlPaperLetterSmall = $00000002;
xlPaperNote = $00000012;
xlPaperQuarto = $0000000F;
xlPaperStatement = $00000006;
xlPaperTabloid = $00000003;
xlPaperUser = $00000100;
 
收到 明天回公司试试
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1211360
 
接受答案了.
 
后退
顶部