开发者

Conversion of Excel / Access / Text file into UTF-16LE format

I need to write a conve开发者_如何学JAVArter 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!


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;
?>


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜