如何从查询结果导出html表到php中的docx

时间:2016-09-28 05:55:09

标签: php html mysql

嘿,我使用tableExport插件进行html表导出。这里我的html表是由查询结果组成的。我想将该表导出为word格式。但导出的格式不像字。请帮帮我..

<script src="<? echo base_url(); ?>application/assets/js/jquery-1.10.1.min.js" type="text/javascript"></script>
<script type="text/javascript" src="<? echo base_url(); ?>application/assets/js/table_export/tableExport.js"></script>
<script type="text/javascript" src="<? echo base_url(); ?>application/assets/js/table_export/jquery.base64.js"></script>
<script type="text/javascript">
    $(document).ready(function (e) {
        $("#doc_id").click(function (e) {
            $("#sample_editable_1").tableExport(function (e) {
                type :'doc'

            });
        });
    });
</script>

<table class="table striped hover bordered" id="sample_editable_1">
    <thead>
    <tr>
        <th rowspan="2" id="eval_style">Roll No</th>
        <th rowspan="2" id="eval_style">Student Name</th>
        <?php foreach($subject_list->result() as $row_subject) { ?>
            <th rowspan="2" id="eval_style"><?php echo $row_subject->subject_name; ?></th>
        <? } ?>
        <th rowspan="2" id="eval_style">View</th>
    </tr>
    </thead>
    <tbody>
    <?php if( $narrative != '' ) {
        $result1 = $narrative->result_array();
        for($i = 0; $i < count($result1); $i ++) {
            ?>
            <tr>
                <td><? echo $result1[ $i ]['roll_num']; ?></td>
                <td><? echo $result1[ $i ]['student_name']; ?></td>
                <?php for($j = 0; $j < count($subject1); $j ++) {
                    $col = 'narrative_'.$subject1[ $j ];
                    if( $result1[ $i ][ $col ] != '' ) {
                        ?>
                        <td><? echo $result1[ $i ][ $col ]; ?></td>
                    <? }
                    else {
                        ?>
                        <td><? echo "-"; ?></td>
                    <? } ?>


                <? } ?>
                <td id="table_body">
                </td>
            </tr>
        <? }
    } ?>
    </tbody>
</table>

1 个答案:

答案 0 :(得分:0)