I create the following folder: C:\xampp\htdocs\intranet\testes\aspose
At command line (as administrator) in that folder I run: composer require aspose/storage-sdk-php
At command line (as administrator) in that folder I run: composer require aspose/cells-sdk-php
At C:\xampp\htdocs\intranet\testes\aspose\test_git.php with the example code:
<?php
require_once('vendor/autoload.php'); //I replaced: require_once realpath(__DIR__ . '/..') . '/vendor/autoload.php';
use Aspose\Cells\CellsApi;
use Aspose\Cells\AsposeApp;
class Workbook {
public $cells;
public function __construct() {
AsposeApp::$clientId = Utils::clientId;
AsposeApp::$clientSecret = Utils::clientSecret;
$this->cells = new CellsApi( AsposeApp::$clientId,AsposeApp::$clientSecret );
}
public function postImportDataCloudFile() {
$name ='Book1.xlsx';
$folder = "PhpTest";
$data = new ImportIntArrayOption();
$data->setDestinationWorksheet('Sheet1');
$data->setFirstColumn(1);
$data->setFirstRow(3);
$data->setImportDataType('IntArray');
$data->setIsVertical('true');
$data->setData(array(1, 2, 3, 4)) ;
$this->instance->uploadFile($folder + "/" + $name , $sourceFolder + $name);
$result = $this->instance->cellsWorkbookPostImportData($name, $data, $folder);
}
}
$workbook = new Workbook();
$workbook->postImportDataCloudFile();
?>
It gives me an error saying: Fatal error : Uncaught Error: Class “Utils” not found in C:\xampp\htdocs\intranet\testes\aspose\test_git.php:13 Stack trace: #0 C:\xampp\htdocs\intranet\testes\aspose\test_git.php(34): Workbook->__construct() #1 {main} thrown in C:\xampp\htdocs\intranet\testes\aspose\test_git.php on line 13
NOTES:
I don’t know where to put the credentials “Client ID” and “Client Secret”.
Can you help me please? Or maybe you can gives me an example?
@wangtao
Thanks for the answer.
I used your example and I get the following error: image.png (40.1 KB)
The only change I made was change the $sourceFolder:
//$sourceFolder = “D:\projects\aspose\aspose.cells.cloud.sdk\examples\php-sdk-examples\”;
$sourceFolder = “C:\xampp\htdocs\intranet\testes\aspose\”;
In fact, that line: $this->cells = new CellsApi(‘your client id’,‘your client secret’,‘v3.0’,‘https://api.aspose.cloud/’);
made the all difference for me.
Another difficult that I have is about obsolete documentation.
For example, in the page SaveAs Excel|Aspose.Cells Cloud Document I use the example shown on PHP separator and I’ve got the error on the line:
CellsApiTestBase::ready( $this->instance,$name ,$folder);
Maybe it’s because AsposeApp is not present on SDK.