简体   繁体   中英

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

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM