Convert the Excel file stored on the server side to a csv file using the PHPExel library and
I want to save it as a new csv file.
Image of Excel file already stored on server side (juuu.xls)
item1 item2 item3
2 3 6
The csv file you want to convert
item1, item2, item3
2,3,6
Excel file image already stored on server side (juchuu.xls)
item1 item2 item3
2 3 6
New csv file you want to convert
item1, item2, item3
2,3,6
**<?php
echo "Step 0";
require_once(DIR."/lib/PHPExcel.php");
require_once(DIR."/lib/PHPExcel/IOFactory.php");
echo "Step 1";
// Generate PHPExcel object
$reader=PHPExcel_IOFactory::createReader("Excel 2007");
echo "Step 2";
// Load Excel
book=book=objReader->load('./juchuu.xls');
echo "Step 3";
// Save CSV
writer=PHPExcelIOFactory::createWriter(writer=PHPExcelIOFactory::createWriter(book, 'csv');
$writer->save('./juchuu3.csv');?>**
What's wrong?
Convert xls files to CSV in PHPExcel - Qiita
php csv excel
Cubick has already commented, but in PHPExcel,
PHPExcel last version, 1.8.1, was released in 2015. The project was officially prepared in 2017 and permanently archived in 2019.
The project has not been maintained for years and must not be used anymore. All users must migrate to its direct successor PhpSpreadsheet, or another alternative.
So I think you should follow it.
$reader=PHPExcel_IOFactory::createReader("Excel 2007");
For now, Excel 2007
is the so-called .xlsx
format. If you are dealing with the .xls
format, you must specify Excel5
.The Qiita article also says so.
(By the way, there is no room for u
in spelling because key)
© 2024 OneMinuteCode. All rights reserved.