就设置了下面这些属性,没有任何其他操作,预览窗口出来前居然需要3秒以上的时间,请问有没有什么优化方法。从Excel里可以看到,好像每执行一个属性赋值,Excel就重画一次,状态栏不停闪烁“就绪”,影藏Excel显示设置ScreenUpdating为False也没用,执行这些页面设置用时一样....表数据很小,唯一的要求就是按照格式打印出来,可这个速度真叫人郁闷了...        wb.OlePropertyGet("PageSetup").OlePropertySet("PrintArea", AnsiString(strArea).c_str());// wb.OlePropertyGet("PageSetup").OlePropertySet("PrintHeadings", false); wb.OlePropertyGet("PageSetup").OlePropertySet("BlackAndWhite", true); wb.OlePropertyGet("PageSetup").OlePropertySet("PaperSize", 9); wb.OlePropertyGet("PageSetup").OlePropertySet("Zoom", false);
wb.OlePropertyGet("PageSetup").OlePropertySet("FitToPagesWide", 1);
wb.OlePropertyGet("PageSetup").OlePropertySet("FitToPagesTall", 1); // 1纵向,2横向
wb.OlePropertyGet("PageSetup").OlePropertySet("Orientation", Orientation); wb.OlePropertyGet("PageSetup").OlePropertySet("CenterHorizontally", true);
wb.OlePropertyGet("PageSetup").OlePropertySet("CenterVertically", false); wb.OlePropertyGet("PageSetup").OlePropertySet("LeftMargin", 0.3);
wb.OlePropertyGet("PageSetup").OlePropertySet("RightMargin", 0.3);
wb.OlePropertyGet("PageSetup").OlePropertySet("TopMargin", 0.3);
wb.OlePropertyGet("PageSetup").OlePropertySet("BottomMargin", 0.3);
wb.OlePropertyGet("PageSetup").OlePropertySet("HeaderMargin", 0.3);
wb.OlePropertyGet("PageSetup").OlePropertySet("FooterMargin", 0.3);

解决方案 »

  1.   

    这么说吧,两个表,一个有数据需要打印,一个无数据,提起设置好打印样式。
    把1表内容拷贝到2表打印,速度都比设置上面这些PageSetup参数快.....
      

  2.   

    楼主跑Delphi版问来了?可以考虑先根据样式设计好模板,然后根据这个模拟新建一个Excel文档,然后将要打印的数据复制过来,再打印.
      

  3.   

    妖哥,只有你给我回帖啊....我整个项目里任何操作没有超过500毫秒的。弄个Excel打印居然要2-3秒,实在不能接受,就不理解怎么设置个PageSetup就这么慢。不过我在excel里自己录制这些操作的宏,运行一下也不是很快.....