Article

Use Gemini API to read selected pages and spreadsheet cells

For document-assistant teams, select PDF pages or spreadsheet cells, choose text or visuals, and estimate input costs without overlooking file limits.

Editorial illustration for Use Gemini API to read selected pages and spreadsheet cells: a geometric block represents a model release. Not documentary evidence.

Google’s November 18, 2026 Gemini API update lets document-assistant teams select PDF pages or spreadsheet cells through processing options, rather than send every page or sheet to the model.

Google says document token billing covers the selected content. The complete source file is still uploaded and must meet the file limits: selecting less for the model is not the same as uploading less to Google.

Choose a supported model and check the whole file

Google documents these controls for Gemini 3 and Gemini 4 models, both in user inputs and in results returned by tools. They cover PDFs, Word-family documents, PowerPoint-family presentations and Excel/OpenDocument spreadsheets. This is an API workflow for software builders, not a setting in the consumer Gemini app.

Upload through the Files API or supply supported inline data, using the file’s matching MIME type. The document-processing limits still apply to the complete original, even when requesting a small selection:

  • 50 MB per file.

  • 1,000 pages per PDF, or 2,000 pages or slides per Office/OpenDocument file.

  • 50,000 cells per spreadsheet sheet.

Check the project’s data-use terms before uploading business records. If excluded material must not leave your application, prepare a reduced file before upload. Server-side slicing is not a redaction step.

Select pages and decide whether you need images

The following documentation-derived fragment belongs in the input list of a Gemini Interactions API request, alongside the question. Replace the URI placeholder with a valid uploaded file URI and choose a supported model. These fragments have not been executed and are not complete requests; check that your installed SDK exposes these fields rather than assuming an older client or another API interface accepts them.

To read pages 3 through 7 as rendered images, use this document block. Both endpoints count, so it selects five pages:

{
  "type": "document",
  "uri": "YOUR_UPLOADED_FILE_URI",
  "mime_type": "application/pdf",
  "resolution": "medium",
  "processing": {
    "type": "static",
    "page_options": {
      "start_page": 3,
      "end_page": 7,
      "content_layers": [
        "page_image"
      ]
    }
  }
}

Choose page_text for extracted text when the question does not depend on visual evidence. Choose page_image when it depends on charts, diagrams or layout; both layers can be requested. Google suggests scanning large Office files as text first, then requesting high-resolution images of pages needing closer inspection. resolution belongs on the outer document block, not inside page_options.

Set the range and layers explicitly. Under Google’s documented defaults, omitting the start selects from page 1; omitting the end selects through the final page. With processing set, the default layer is page_image, not extracted text.

Validate ranges before sending them. A start of 0 or less returns 400 INVALID_ARGUMENT; a start beyond the page count produces an empty slice. An end beyond the document is capped at its last page, and the end cannot precede the start. Treat an empty slice as missing evidence, not as proof that the document has nothing relevant.

Select a worksheet, cells and the right evidence

For a spreadsheet, sheet_index counts tabs from 1. This fragment selects the second worksheet’s A1:H50 range, with cell values and raw formulas:

{
  "type": "document",
  "uri": "YOUR_UPLOADED_FILE_URI",
  "mime_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
  "processing": {
    "type": "static",
    "spreadsheet_options": {
      "sheet_index": 2,
      "visible_cells": "A1:H50",
      "content_layers": [
        "data",
        "formulas"
      ]
    }
  }
}

The layer choice should follow the question:

  • data supplies evaluated cell values for a lookup or summary.

  • formulas supplies raw formulas when you need to explain how a value is derived. Include referenced cells if the explanation depends on them; receiving a formula is not proof that it has been independently recalculated.

  • visual supplies a rendered sheet snapshot for charts and layout. Add it when needed, with resolution on the document block.

Google’s spreadsheet options default to values and formulas, without the visual layer. Omitting sheet_index selects all sheets; an index outside the valid tab positions returns 400 INVALID_ARGUMENT. The visible_cells range crops every selected layer, so a visual request is still restricted to that region.

For a hypothetical sales workbook, a number in the selected cells may depend on a heading, currency label or formula reference elsewhere. Include those dependencies or retrieve them before interpreting the number. Verify tab order against the uploaded workbook version: “second sheet” need not identify the same worksheet after someone rearranges it.

Calculate the page-image charge, not the whole bill

For Gemini 3 and 4 documents, Google lists approximately 280, 560 and 1,120 image tokens per page at low, medium and high resolution respectively. Tokens are the units used to count model input and output.

Illustrative calculation, not a measured workload: assume an eligible 100-page PDF, only the page_image layer, medium resolution, and no caching or other discount. Compare all 100 pages with 10 pages assumed sufficient for the question. Gemini 4 Hydrogen’s Standard paid input rate is US$1.50 per million tokens as of November 18, 2026.

  • All 100 pages: 100 × approximately 560 = 56,000 page-image tokens; 56,000 ÷ 1,000,000 × US$1.50 = about US$0.084.

  • Selected 10 pages: 10 × approximately 560 = 5,600 page-image tokens; 5,600 ÷ 1,000,000 × US$1.50 = about US$0.0084.

That is about 8.4 US cents versus 0.84 cents for this input component. The 90% reduction follows from selecting one tenth as many pages at the same resolution; it is not evidence of equal answer quality or a 90% reduction in the total invoice.

Text instructions, any other billed content, output, thinking, additional turns and tools remain outside this calculation. Hydrogen’s Standard paid output rate is US$7.50 per million tokens, including thinking. Do not infer a universal per-cell spreadsheet price from these page-image figures. See Gemini 4 Hydrogen access and pricing for the separate free-versus-paid access question and data conditions.

Let the assistant fetch context it has not read

The same document block can be returned inside a tool’s function_result.result list. Google’s function-response example carries forward the function call’s call_id and name, then continues the conversation using previous_interaction_id. Page counts and worksheet names are supplied automatically, helping the model request another range.

That metadata is an index, not evidence that the assistant has read every page. Keep file identity and selected ranges with the answer, apply your application’s access checks to follow-up requests, and distinguish “outside the selected range” from “absent from the document.” If an answer needs a missing footnote or worksheet, retrieve it before drawing the conclusion.

A related pattern for a different platform is keeping large JSON tool results out of AgentCore prompts: retain the full source and provide a way to fetch what the first selection omits. The implementation differs, but the reader’s need is the same—less input without losing the evidence required for the answer.

Before rollout, compare selected-range answers against known answers from representative permitted files, and record actual usage across the complete conversation. Keep the smallest selection that answers the question with its necessary context, rather than the smallest selection that returns a response.