用flex如何制作不规则的表格,进行打印预览。而且可以打印。譬如制作如下表单:

来源:互联网 发布:淘宝怎么转卖东西 编辑:程序博客网 时间:2024/05/04 07:13

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="vertical"
    horizontalScrollPolicy="off"
    verticalScrollPolicy="off">
    
    <mx:Script>
        <![CDATA[
            import mx.printing.FlexPrintJob;
            
            private function printResume():void
            {
                var printJob:FlexPrintJob = new FlexPrintJob();
                printJob.start();
                printJob.addObject(resume);
                printJob.send();
            }
        ]]>
    </mx:Script>
    
    <mx:Style>
        Application
        {
            paddingLeft: 0;
            paddingRight: 0;
            paddingTop: 0;
            paddingBottom: 0;
            verticalGap: 0;
            fontSize: 12;
        }
        
        .resume
        {
            backgroundAlpha: 1;
            backgroundColor: #FFFFFF;
            borderColor: #888888;
            borderStyle: solid;
            borderThickness: 1;
            paddingLeft: 15;
            paddingRight: 15;
            paddingTop: 15;
            paddingBottom: 15;
            verticalGap: 0;
        }
        
        Grid
        {
            backgroundAlpha: 1;
            backgroundColor: #FFFFFF;
            borderColor: #000000;
            borderSides: "right bottom";
            borderStyle: solid;
            borderThickness: 1;
            horizontalGap: 0;
            verticalGap: 0;
        }
        
        GridItem
        {
            borderColor: #000000;
            borderSides: "left top";
            borderStyle: solid;
            borderThickness: 1;
        }
        
        .title
        {
            fontSize: 24;
            textAlign: center;
        }
        
        .photo
        {
            borderColor: #000000;
            borderSides: "left top";
            borderStyle: solid;
            borderThickness: 1;
            paddingLeft: 2;
            paddingRight: 2;
            paddingTop: 2;
            paddingBottom: 2;
        }
        
        .box
        {
            verticalGap: 0;
        }
    </mx:Style>
    
    <mx:ApplicationControlBar width="100%">
        <mx:Button label="打印简历" click="printResume()" />
    
    </mx:ApplicationControlBar>
    <mx:Canvas width="100%" height="100%">
        <mx:VBox id="resume"
            x="20" y="20" width="492" height="620" styleName="resume">
            <mx:Spacer height="12" />
            <mx:Label width="100%" text="个人简历" styleName="title" />
            <mx:Spacer height="8" />
            <mx:Grid width="460" height="523">
                <mx:GridRow height="21">
                    <mx:GridItem width="70">
                        <mx:Label text="姓名" />
                    </mx:GridItem>
                    <mx:GridItem width="110">
                        <mx:Label text="北京人甲" />
                    </mx:GridItem>
                    <mx:GridItem width="70">
                        <mx:Label text="性别" />
                    </mx:GridItem>
                    <mx:GridItem width="110">
                        <mx:Label text="男" />
                    </mx:GridItem>
                    <mx:GridItem width="99" rowSpan="5" styleName="photo">
                        <mx:Image width="90" height="100"
                            source="http://www.javaeye.com/upload/logo/user/81174/5415ac9b-162c-317c-8c9c-aa5cd2c1d6c4.jpg?1236837636" />
                    </mx:GridItem>
                </mx:GridRow>
                <mx:GridRow height="21">
                    <mx:GridItem width="70">
                        <mx:Label text="出生日期" />
                    </mx:GridItem>
                    <mx:GridItem width="110">
                        <mx:Label text="-200000-1-1" />
                    </mx:GridItem>
                    <mx:GridItem width="70">
                        <mx:Label text="籍贯" />
                    </mx:GridItem>
                    <mx:GridItem width="110">
                        <mx:Label text="北京周口店" />
                    </mx:GridItem>
                </mx:GridRow>
                <mx:GridRow height="21">
                    <mx:GridItem width="70">
                        <mx:Label text="姓名" />
                    </mx:GridItem>
                    <mx:GridItem width="110">
                        <mx:Label text="张三" />
                    </mx:GridItem>
                    <mx:GridItem width="70">
                        <mx:Label text="性别" />
                    </mx:GridItem>
                    <mx:GridItem width="110">
                        <mx:Label text="男" />
                    </mx:GridItem>
                </mx:GridRow>
                <mx:GridRow height="21">
                    <mx:GridItem width="70">
                        <mx:Label text="民族" />
                    </mx:GridItem>
                    <mx:GridItem width="110">
                        <mx:Label text="暂缺" />
                    </mx:GridItem>
                    <mx:GridItem width="70">
                        <mx:Label text="政治面貌" />
                    </mx:GridItem>
                    <mx:GridItem width="110">
                        <mx:Label text="群众" />
                    </mx:GridItem>
                </mx:GridRow>
                <mx:GridRow height="21">
                    <mx:GridItem width="70">
                        <mx:Label text="身高" />
                    </mx:GridItem>
                    <mx:GridItem width="110">
                        <mx:Label text="164cm" />
                    </mx:GridItem>
                    <mx:GridItem width="70">
                        <mx:Label text="健康状况" />
                    </mx:GridItem>
                    <mx:GridItem width="110">
                        <mx:Label text="优秀" />
                    </mx:GridItem>
                </mx:GridRow>
                <mx:GridRow height="21">
                    <mx:GridItem width="70">
                        <mx:Label text="学历" />
                    </mx:GridItem>
                    <mx:GridItem width="110">
                        <mx:Label text="无" />
                    </mx:GridItem>
                    <mx:GridItem width="70">
                        <mx:Label text="毕业院校" />
                    </mx:GridItem>
                    <mx:GridItem width="110" colSpan="2">
                        <mx:Label text="北京周口店社会大学" />
                    </mx:GridItem>
                </mx:GridRow>
                <mx:GridRow height="21">
                    <mx:GridItem colSpan="5">
                        <mx:Label text="◇教育经历◇" />
                    </mx:GridItem>
                </mx:GridRow>
                <mx:GridRow height="78">
                    <mx:GridItem colSpan="5" />
                </mx:GridRow>
                <mx:GridRow height="21">
                    <mx:GridItem colSpan="5">
                        <mx:Label text="◇工作经验◇" />
                    </mx:GridItem>
                </mx:GridRow>
                <mx:GridRow height="78">
                    <mx:GridItem colSpan="5">
                        <mx:Label text="本人擅长打猎、捕鱼、采集野果、制作石器、生火等,有20年以上工作经验。" />
                    </mx:GridItem>
                </mx:GridRow>
                <mx:GridRow height="21">
                    <mx:GridItem colSpan="5">
                        <mx:Label text="◇项目经验◇" />
                    </mx:GridItem>
                </mx:GridRow>
                <mx:GridRow height="78">
                    <mx:GridItem colSpan="5">
                        <mx:VBox styleName="box">
                            <mx:Label text="猎野猪(与他人合作完成)" />
                            <mx:Label text="捡兔子(野火烧熟的)" />
                            <mx:Label text="曾独立捕到一人长大鲤鱼一条" />
                        </mx:VBox>
                    </mx:GridItem>
                </mx:GridRow>
                <mx:GridRow height="21">
                    <mx:GridItem colSpan="5">
                        <mx:Label text="◇自我评价◇" />
                    </mx:GridItem>
                </mx:GridRow>
                <mx:GridRow height="78">
                    <mx:GridItem colSpan="5">
                        <mx:Label text="乐观向上、有团队合作精神" />
                    </mx:GridItem>
                </mx:GridRow>
            </mx:Grid>
        </mx:VBox>
    </mx:Canvas>
    
</mx:Application>