Skip to content

Documentation

PHP SDK: Documents: read from a website or from bytes

$ctx->documents() reads Excel, PDF, Word, CSV, and text files. Use the shared document service instead of installing libraries or opening the file system. It does not run macros, formulas, JavaScript, or external links embedded in documents.

fromUrl

fromUrl(string $url, string $name = 'document'): Document

Download a file up to 10 MiB through the current source's network settings. Address, redirect, robots.txt, request-rate, and proxy rules still apply. The name is taken from the URL; supply it as the second argument if the URL has no extension.

$document = $ctx->documents()->fromUrl('https://example.com/files/catalog.xlsx');
foreach ($document->rows('Stock') as $row) {
    $ctx->log(json_encode($row, JSON_UNESCAPED_UNICODE));
}

fromBytes

fromBytes(string $content, string $name): Document

Parse bytes you already have, up to 8 MiB. The name helps identify text and older Office formats; the service also checks the content signature.

$document = $ctx->documents()->fromBytes("SKU;Stock\nTEST-001;17", 'report.csv');
$rows = $document->rows();

Both methods return a Document. For email attachments, use Mail::document, which also checks ownership, permissions, and retention.

At most eight documents can be parsed per run. A large document can produce a partial result with complete() = false. Damaged, encrypted, or unsupported files produce a clear error. Document passwords are not passed through.

coordinates

coordinates(): SheetCoordinates

Excel addressing helpers that do not load a document or make a network request.

$coordinates = $ctx->documents()->coordinates();
$name = $coordinates->columnName(27);