Skip to content

Commit 615406c

Browse files
committed
Add convertSpreadsheet() method.
1 parent 33fd477 commit 615406c

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ $wdp->convertHTMLToPDF($source, $targetFilename);
6969

7070
// Convert HTML file to PDF
7171
$wdp->convertHTMLFileToPDF($sourceFilename, $targetFilename);
72+
73+
// Convert spreadsheets
74+
$wdp->convertSpreadsheet($sourceFilename, $targetFilename, 'xls');
7275
```
7376

7477
## Requirements

src/Client.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,4 +397,22 @@ public function takeWebsiteScreenshot(string $url, int $width, string|int $heigh
397397
]);
398398
$this->downloadFile($response['result']['file'], $targetFilename);
399399
}
400+
401+
402+
/**
403+
*
404+
* @param string $sourceFilename
405+
* @param string $targetFilename
406+
* @param string $format
407+
* @param integer $quality
408+
* @return void
409+
*/
410+
public function convertSpreadsheet(string $sourceFilename, string $targetFilename, string $format): void
411+
{
412+
$this->checkSourceFilename($sourceFilename);
413+
$this->checkTargetFilename($targetFilename);
414+
$fileID = $this->uploadFile($sourceFilename);
415+
$response = $this->sendRequest('/v0/spreadsheet-convert', ['file' => $fileID, 'format' => $format]);
416+
$this->downloadFile($response['result']['file'], $targetFilename);
417+
}
400418
}

0 commit comments

Comments
 (0)