使用Ole操作Excel打印表格,速度很慢。求教
就设置了下面这些属性,没有任何其他操作,预览窗口出来前居然需要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);