This technical tip allows developers to split all or specific pages of an Excel document and save each worksheet as PDF, Image or any supported format using Saaspose.Cells REST API in your PHP applications. Input Excel documents need to be uploaded at Amazon S3 Storage before running this code. You need to configure Amazon S3 Storage with Saaspose before using this example. Some important steps for performing this task are to build URI to split sheets, sign URI, iterate through each document in the result to find output sheets, build URI to download split sheets And save split PDF pages.
Sample Code for Splitting Excel Documents at Amazon S3 Storage
SaasposeApp::$AppSID = "77***********************************";
SaasposeApp::$AppKey = "9a*******************************";
SaasposeApp::$OutPutLocation = getcwd() . "\\Output\\";
$AmazonS3StorageName = "AmazonS3Storage";
$AmazonS3BucketName = "Saaspose";
$AmazonS3Folder = $AmazonS3BucketName . "/Folder1"; // use $AmazonS3Folder = $AmazonS3BucketName for root folder
//build URI to split sheets
$strURI = 'http://api.saaspose.com/v1.0/cells/Sample1.xlsx/split?format=png&storage=' . $AmazonS3StorageName . '&folder=' . $AmazonS3Folder;
//sign URI
$signedURI = Utils::Sign($strURI);
$responseStream = Utils::processCommand($signedURI, "POST", "", "");
$json = json_decode($responseStream);
//iterate throug each document in the result to find output sheets
foreach ($json->Result->Documents as $splitSheet) {
$splitFileName = $splitSheet->link->Href;
//build URI to download split sheets
$strURI = 'http://api.saaspose.com/v1.0/storage/file/'. $AmazonS3Folder . '/' . $splitFileName . '?storage=' . $AmazonS3StorageName;
//sign URI
$signedURI = Utils::Sign($strURI);
$responseStream = Utils::processCommand($signedURI, "GET", "", "");
//save split PDF pages
$outputFile = SaasposeApp::$OutPutLocation . $splitFileName;
Utils::saveFile($responseStream, $outputFile);
}
More about Saaspose.Cells
- Homepage of Saaspose.Cells: http://saaspose.com/api/cells
- More Technical Tips by Saaspose.Cells: http://saaspose.com/docs/display/cells/1.2+-+Saaspose.Cells+Examples
- Configure Amazon S3 Storage with Saaspose: http://saaspose.com/docs/display/rest/Amazon+S3+Storage
- Ask technical questions/queries from Saaspose Support Team: http://saaspose.com/support/contact-us
Contact Information
Aspose Pty Ltd, Suite 163,
79 Longueville Road
Lane Cove, NSW, 2066
Australia
http://www.saaspose.com/
sales@saaspose.com
Phone: 1.214.329.1520
Fax: 866.810.9465
|