0

有谁知道如何从 x++ 代码通过 COM 访问 Excel 工作表的 PageSetup 属性。我可以执行自定义报告所需的所有格式设置,但无法访问 PageSetup 对象。

任何指针/建议表示赞赏。

4

1 回答 1

1

http://axforum.info/forums/showthread.php?p=209139#post209139

#define.xlDialogPageSetup(7)
static void Job212(Args _args)
{
    COM doc = ; // HERE IS EXCEL DOCUMENT COM OBJECT
    COM app;
    COM worksheet;
    COM pageSetup;
    COM temp;

    int fitToPagesWide = 5; 
    int fitToPagesTall = 0; 

    COMVariant cvZoom = COMVariant::createFromBoolean(false);
    COMVariant cvWide = fitToPagesWide ? COMVariant::createFromInt( fitToPagesWide ) 
                                       : COMVariant::createFromBoolean( false );
    COMVariant cvTall = fitToPagesTall ? COMVariant::createFromInt( fitToPagesTall )
                                       : COMVariant::createFromBoolean( false )    ;
    ;
    app = doc.Application();

    worksheet = app.ActiveSheet();
    pageSetup = worksheet.PageSetup();

    pageSetup.Zoom(cvZoom);
    pageSetup.FitToPagesWide(cvWide);
    pageSetup.FitToPagesTall(cvTall);

    // это для демонстрации того, что получается
    temp = app.Dialogs();
    temp = temp.Item(#xlDialogPageSetup);
    temp.Show();
于 2010-01-22T20:11:53.030 回答