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是分页打印不可缺少的部分。
时间: 2024-10-26 15:19:20