Convert a XLS file to CSV in PHP
API Request:
PUT
https://api.aspose.cloud/v3.0/cells/convert
Converting file formats from XLS to CSV is a complex task. All XLS to CSV format transitions is performed by our PHP SDK while maintaining the source XLS spreadsheet's main structural and logical content. Our PHP library is a professional solution to convert XLS to CSV files online. This Cloud SDK gives PHP developers powerful functionality and perfect CSV output.
Code example in PHP using REST API to convert XLS to CSV format
// For complete examples and data files, please go to https://github.com/aspose-cells-cloud/aspose-cells-cloud-php/
<?php
require_once('vendor\autoload.php');
use \Aspose\Cells\Cloud\Api\CellsApi;
$instance = new CellsApi(getenv("ProductClientId"),getenv("ProductClientSecret"));
$path ='Book1.xls';
$format ='csv';
$password = null;
$outPath = null;
$result = $this->instance->cellsWorkbookPutConvertWorkBook($path ,$format, $password, $outPath);
$size = $result->getSize();
$content = $result->fread($size);
$file = fopen("destfile.csv", 'w');
fwrite($file,$content);
fclose($file);
How to use PHP API to convert XLS to CSV
- Create an account at Dashboard to get free API quota & authorization details
- Initialize CellsApi with Client Id, Client Secret, Base URL & API version
- Call cellsWorkbookPutConvertWorkBook method to get the resultant stream
System Requirements
- PHP 7.4 or newer