将 Excel / Access / Text 文件转换为 UTF-16LE 格式

发布于 2024-10-04 06:03:05 字数 209 浏览 0 评论 0原文

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

有什么想法、技巧或者可能已经写好的代码吗?


谢谢!

I need to write a converter which will accept as input Excel, Access or Text file and convert it to UTF-16LE format. I would like to integrate that module into some PHP code which already exists and which acts as a 'management interface' to an underlying MS SQL Server application.

Any ideas, tips or maybe already written code?


Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

醉生梦死 2024-10-11 06:03:05

您需要两个文件才能将文本文件转换为 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;
?>

You need two files for converting a text file into excel file. One would be your text file, say test.txt and an excel file newfile.xls.
The below script can be executed to obtain the desired result.

<?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;
?>
花开柳相依 2024-10-11 06:03:05

我会看一下 PHP 的 iconv 库。我之前在类似的情况下使用过它,在将 Excel 输入插入数据库之前需要访问/转换它。

I would take a look at PHP's iconv library. I have used it in a similar situation before where I needed to access/convert Excel input before inserting it into my database.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文