'. htmlspecialchars ($withVarTypes ? $var : print_r ($var, true)). ''; } // Create new instance header('Content-Type: text/html; charset=utf-8'); require_once 'Excel/reader.php'; $excelData = new Spreadsheet_Excel_Reader(); $excelData->setOutputEncoding('UTF-8'); $excelData->read('test.xls'); // Define how many rows and columns are there - we will automaticly increase rows and columns at reading $excelData->sheets[0]['numRows'] = 1; $excelData->sheets[0]['numCols'] = 1; // Get data $data = array(); for ($i = 1; $i <= $excelData->sheets[0]['numRows']; $i++) { for ($j = 1; $j <= $excelData->sheets[0]['numCols']; $j++) { if (isset($excelData->sheets[0]['cells'][$i][$j])) { // Convert date to our format if ($excelData->sheets[0]['cellsInfo'][$i][$j]['type'] == 'date') { $excelData->sheets[0]['cells'][$i][$j] = date('d.m.Y', $excelData->sheets[0]['cellsInfo'][$i][$j]['raw']); } // Add field into data array $data[$i][] = $excelData->sheets[0]['cells'][$i][$j]; // If this is first row count number of columns if ($i == 1) { $excelData->sheets[0]['numCols']++; } } } // If the row was not empty continue with reading if (!empty($data[$i][0])) { $excelData->sheets[0]['numRows']++; } } // Transform excel file to .txt file - add BOM char at the start - only for wordpad - notepad support $textFile = "\xEF\xBB\xBF"; foreach($data as $row) { // Get last key end($row); $lastKey = key($row); reset($row); foreach($row as $key => $field) { $textFile .= $field; if ($key != $lastKey) { $textFile .= "\t"; } } $textFile .= "\n"; } file_put_contents('test.txt', $textFile); ?>