【问题标题】:Conversion of Excel / Access / Text file into UTF-16LE formatExcel / Access / 文本文件转换为 UTF-16LE 格式
【发布时间】:2010-11-26 22:00:22
【问题描述】:

我需要编写一个转换器,它将接受 Excel、Access 或文本文件作为输入并将其转换为 UTF-16LE 格式。我想将该模块集成到一些已经存在并充当底层 MS SQL Server 应用程序的“管理接口”的 PHP 代码中。

有什么想法、提示或可能已经编写好的代码?


谢谢!

【问题讨论】:

    标签: php sql-server utf-16


    【解决方案1】:

    您需要两个文件来将文本文件转换为 excel 文件。一个是您的文本文件,例如 test.txt 和一个 Excel 文件 newfile.xls。
    可以执行以下脚本以获得所需的结果。

    <?php
        $csv_output .= "\n";   
        $filename = "newfile.xls"; //Name of the excel file needed     
        $textfiledata = file_get_contents('test.txt'); //Name of the txt file
        $csv_output .= $textfiledata;
    
        header("Content-type: application/vnd.ms-excel");
        header("Content-disposition: csv" . date("Y-m-d") . ".xls");
        header("Content-disposition: filename=" . $filename . ".xls");
        print $csv_output;
        exit;
    ?>
    

    【讨论】:

      【解决方案2】:

      我会看看 PHP 的 iconv library。在将 Excel 输入插入数据库之前,我曾在类似的情况下使用过它。

      【讨论】:

        猜你喜欢
        • 2022-06-14
        • 2012-06-01
        • 2015-01-14
        • 1970-01-01
        • 1970-01-01
        • 2018-01-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多