码迷,mamicode.com
首页 > 其他好文 > 详细

flex 分页打印表格功能

时间:2015-02-03 21:10:37      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:

private function printHandler():void{
            var printJob:FlexPrintJob = new FlexPrintJob();
            printJob.printAsBitmap = true;
            if (printJob.start()){
                    var myPrintData:PrintDataGrid=new PrintDataGrid();
                    var dataCol:DataGridColumn = new DataGridColumn();
                    dataCol.headerText = "序号";
                    dataCol.dataField= "NUM";
                    dataCol.width = 60;
                    var dataCol0:DataGridColumn = new DataGridColumn();
                    dataCol0.headerText = "拐点号";
                    dataCol0.dataField= "GDH";
                    dataCol0.width = 60;
                    var dataCol1:DataGridColumn = new DataGridColumn();
                    dataCol1.headerText = "X_坐标(起标高)";
                    dataCol1.dataField= "XZB";
                    dataCol1.width = 125;
                    var dataCol2:DataGridColumn = new DataGridColumn();
                    dataCol2.headerText = "Y_坐标(止标高)";
                    dataCol2.dataField= "YZB";
                    dataCol2.width = 125;
                    var dataCol3:DataGridColumn = new DataGridColumn();
                    dataCol3.headerText = "矿体标识";
                    dataCol3.dataField= "KTBS";
                    dataCol3.width = 220;
                    var dataCol4:DataGridColumn = new DataGridColumn();
                    dataCol4.headerText = "性质";
                    dataCol4.dataField= "XZ";
                    dataCol4.width = 60;
                    myPrintData.columns = myPrintData.columns.concat(dataCol)
                    myPrintData.columns = myPrintData.columns.concat(dataCol0)
                    myPrintData.columns = myPrintData.columns.concat(dataCol1);
                    myPrintData.columns = myPrintData.columns.concat(dataCol2);
                    myPrintData.columns = myPrintData.columns.concat(dataCol3);
                    myPrintData.columns = myPrintData.columns.concat(dataCol4);
                    Application.application.addChild(myPrintData);
                    myPrintData.dataProvider = dgCoord.dataProvider;
                    myPrintData.width=printJob.pageWidth;
                    myPrintData.height=printJob.pageHeight;
                    myPrintData.sizeToPage = true;
                    printJob.addObject(myPrintData);
                    while(myPrintData.validNextPage){
                        myPrintData.nextPage();
                        printJob.addObject(myPrintData);
                    }
                    Application.application.removeChild(myPrintData);
                    printJob.send();
               }
        }
<mx:DataGrid id="dgCoord" right="0" bottom="30" top="30"  left="0" editable="true" width="100%" 
			visible="true" draggableColumns="false" sortableColumns="false" fontFamily="微软雅黑" fontWeight="normal" 
			allowMultipleSelection="true" color="#0b333c" borderThickness="0"
			fontStyle="normal" textDecoration="normal" fontSize="12">
		<mx:columns>
				<mx:DataGridColumn headerText="序号" dataField="NUM" width="10" editable="false" textAlign="center"/>	
				<mx:DataGridColumn headerText="拐点号" dataField="GDH" width="10" textAlign="center"/>			
				<mx:DataGridColumn headerText="X_坐标(起标高)" dataField="XZB" width="23" textAlign="center"/>
				<mx:DataGridColumn headerText="Y_坐标(止标高)" dataField="YZB" width="23" textAlign="center"/>
				<mx:DataGridColumn headerText="矿体标识" dataField="KTBS" width="18" textAlign="center"/>
				<mx:DataGridColumn headerText="性质" dataField="XZ" width="10" textAlign="center"/>				
		</mx:columns>
	</mx:DataGrid>

 PrintDataGrid是分页打印不可缺少的部分。

flex 分页打印表格功能

标签:

原文地址:http://www.cnblogs.com/aegisada/p/4270885.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!