dongli8466 2014-07-04 11:44
浏览 58

将表内容导出到xlsx文件

I am allowing user to allow uploading xlsx file, performing transliteration (arabic to english) and displaying on web page as a table content. (same view as xlsx file).

  1. Can I export table content to xlsx? (cell content should persist their cell position)
  2. Or is it possible to write each processes cell result to xlsx?

Here is the code:

if (isset($_FILES['file'])) {
    header('Content-Type: text/html; charset=UTF-8');
    require_once "simplexlsx.class.php";
    require '../../Arabic.php';
    $Arabic = new I18N_Arabic('Transliteration');
    $xlsx = new SimpleXLSX( $_FILES['file']['tmp_name'] );
    echo '<h1>Parsing Result</h1>';
    echo '<table border="1" cellpadding="3" style="border-collapse: collapse">';
    $eng = array();
    list($cols,) = $xlsx->dimension();  
    foreach( $xlsx->rows() as $k => $r) {
//      if ($k == 0) continue; // skip first row
        echo '<tr>';
        for( $i = 0; $i < $cols; $i++)
        {   
            $temp =  $Arabic->ar2en($r[$i]);    
            echo '<td>'.( (isset($r[$i])) ? $temp : '&nbsp;' ).'</td>';
        }
        echo '</tr>';
    }
    echo '</table>';
}
?>
<h1>Upload</h1>
<form method="post" enctype="multipart/form-data">
*.XLSX <input type="file" name="file"  />&nbsp;&nbsp;<input type="submit" value="Parse" />
</form>
  • 写回答

1条回答 默认 最新

  • duanchoupo1104 2014-07-04 12:14
    关注

    Have a look at PHPExcel library. It is a very complex library for working with Excel documents and you should be able to achieve what you're trying to. I don't know about direct export of html tables, but it should be easy to write a simple method atod this library which will do the conversion.

    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改