CoreGamix — Full-Stack Engineering & Developer ToolsCoreGamix — Full-Stack Engineering & Developer Tools
  • Angular
  • Web Development
    • React & TypeScript
    • Node.js
    • PHP & MySQL
  • Tech & AI News
  • Tools & Plugins
  • About
  • Contact Us
HomeTech & AI News Gemini API File Slicing Controls Ship with Native Office Support: What Changes for Devs

Gemini API File Slicing Controls Ship with Native Office Support: What Changes for Devs

Anil Mehra on November 28, 2026
Tech & AI News Web Development
Gemini API file slicing server-side PDF and Excel token optimization banner
5 Min Read

Google’s new Gemini API file slicing update solves one of the most expensive headaches I’ve hit when building document-heavy AI features. Until now, passing a 90-page vendor contract or a 14-tab Excel budget into a prompt meant paying input tokens for the entire file—or maintaining brittle Node.js and Python pre-parsers just to chop files up yourself.

That changes the billing math overnight. Announced on the Google Developers Blog and rolled out across the official Gemini API documentation, developers can now upload full PDFs, multi-sheet workbooks, audio, and video once, and instruct Google’s servers to load only the exact pages, cell ranges, or timestamps needed for a single turn.

In addition, Google added native upload support for Microsoft Office (.xlsx, .docx, .pptx) and OpenDocument files without forcing you to convert everything to PDF or CSV first. Here’s what shipped, how the new request parameters work in code, and where I’m already swapping out custom parsers.

What Shipped in Gemini API File Slicing

First, let’s separate marketing headlines from what actually changed at the SDK level. Previously, uploading a file via the Files API cached the asset, yet referencing that URI inside a prompt still pulled the whole file into the context window.

Now, however, you attach a processing block directly on the input part:

  • Spreadsheet tab and A1 cell crops: Target a specific 1-indexed worksheet (sheet_index) and crop an exact A1 range like "A1:G40" via visible_cells.
  • Selectable spreadsheet layers: Choose whether the model inspects evaluated "data", raw "formulas", or rendered chart "visuals"—so you don’t burn vision tokens when you only need formula audits.
  • PDF page ranges & media segments: Load pages 12–15 of a 200-page compliance PDF or a 45-second clip from a recorded meeting without re-encoding files on your own backend.
  • Dynamic slicing inside tool responses: An AI agent can inspect a table of contents on turn one, then return slice coordinates inside a function_result on turn two to zoom in on a single section.
Gemini API file slicing workflow from Excel upload to Sheet 2 cell slice and reduced token billing
How server-side file slicing isolates Sheet 2 (A1:F35) without sending all 14 tabs into the prompt context.

Code Example: Slicing an Excel Workbook Without CSV Glue Code

In my own full-stack apps—whether I’m wiring a Node.js backend for an Angular Gemini AI workflow or handling file uploads from a type-safe React form—I used to install xlsx or pdf-lib just to trim user uploads before calling the LLM. Now you upload the raw .xlsx file once and slice it per query:

// slice-workbook.ts — TypeScript / Node.js example with @google/genai
import { GoogleGenAI } from '@google/genai';

const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });

export async function auditQuarterlyVariance(localFilePath: string) {
  // 1. Upload the raw Excel workbook once (no CSV conversion needed)
  const workbook = await ai.files.upload({
    file: localFilePath,
    config: {
      mimeType:
        'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
    },
  });

  // 2. Load ONLY Sheet 2, cells A1:F35, inspecting values + raw formulas
  const interaction = await ai.interactions.create({
    model: 'gemini-3.7-flash',
    input: [
      {
        type: 'document',
        uri: workbook.uri,
        mimeType: workbook.mimeType,
        processing: {
          type: 'static',
          spreadsheetOptions: {
            sheetIndex: 2, // 1-indexed worksheet position
            visibleCells: 'A1:F35',
            contentLayers: ['data', 'formulas'],
          },
        },
      },
      {
        type: 'text',
        text: 'Flag any broken SUM/INDEX formulas or >15% Q3 margin drops in this range.',
      },
    ],
  });

  return interaction.outputText;
}

Notice what disappeared from our dependency tree. We didn’t install a third-party spreadsheet parser, we didn’t flatten formulas into dead strings, and we didn’t pay for the other thirteen tabs sitting in that workbook.

Before vs. After Gemini API File Slicing

To see why this update matters for production unit economics, compare how a typical 150-page PDF or 10-tab financial model behaved before versus today:

Workflow DimensionLegacy Full-File IngestionServer-Side File Slicing
Input Token BillingBilled for 100% of pages/tabs on first uncached turnBilled only for the sliced pages, cells, or timestamps
Office Formats (.xlsx, .docx)Required custom LibreOffice / SheetJS conversionNative server-side ingestion out of the box
Excel Formula VisibilityLost during CSV export unless custom-serializedPreserved via contentLayers: ['formulas']
Time-to-First-Token LatencySlow on 50+ MB documentsSignificantly faster on narrow slices

Two Caveats Worth Knowing Before You Refactor

Don’t delete every local parser blindly, though. While testing this pattern against real enterprise documents, two practical trade-offs stand out right away.

1. You Still Need a Way to Know Which Slice to Request

If your users upload unpredictable PDFs where the pricing schedule sits on page 4 in one contract and page 67 in the next, hardcoding pages: '1-5' won’t work. Instead, use a two-step agent pattern: grab the first two index pages cheaply on step one, let the model pick the target page numbers, and fetch that exact slice on step two.

2. Context Caching Still Wins When Every Question Needs the Whole File

On the other hand, if an analyst runs twenty cross-document questions that genuinely span every chapter of a legal brief, slicing five pages at a time risks missing cross-references. In that scenario, explicit Gemini Context Caching on the full document remains the safer architectural choice.

Developer FAQ on Gemini API File Slicing

Does file slicing require re-uploading the document for every query?

No. You upload the source PDF, Office file, or video once via the Gemini Files API, store the returned file.uri, and pass different processing slice coordinates on each subsequent API call without re-transmitting the file bytes.

Are sheet_index values zero-based or one-based?

sheet_index is 1-indexed, matching spreadsheet tab order starting at 1 rather than 0. Therefore, double-check off-by-one indexing if your frontend tab picker uses zero-based array indices.

Anil Mehra on November 28, 2026 Tech & AI News Web Development
previous article
Next article

View comments (1)

Leave a comment Cancel reply

Your email address will not be published. Required fields are marked *

About the Author

Anil Mehra

Anil Mehra

Software Engineer · Google AI Certified

Anil Mehra is a Software Engineer specializing in Angular (NgRx, SignalStore, RxJS), React, TypeScript, Node.js, PHP, and MySQL. Holding the Google AI Professional Certificate, he bridges production web architecture with practical AI-powered workflows.

Google AI Professional Certificate official badge

Google AI Professional Certificate

Google · Coursera Credential ↗

About & Consulting · Instagram · LinkedIn

Recent Guides

  • claude sonnet 4.5 retirement migration guide banner
    Claude Sonnet 4.5 Retirement Hits Today: How I Migrated Node.js Calls to Sonnet 5.5November 30, 2026
  • speculation rules api instant prerender LCP guide banner
    Speculation Rules API Guide: Cut Route LCP to 38ms Without Phantom AnalyticsNovember 30, 2026
  • vite 8.4 release strict allow-list security wasm imports banner
    Vite 8.4 Release Brings Strict Allow-List Dev Security and Wasm Source ImportsNovember 29, 2026
  • Angular linkedSignal TypeScript guide banner showing writable dependent state and previous.value
    Angular linkedSignal in TypeScript: Fix effect() Write Loops & Preserve Previous StateNovember 29, 2026

Engineering Topics

  • Angular 13
  • Frontend Development 4
  • Node.js 3
  • PHP & MySQL 2
  • React & TypeScript 2
  • SEO & Performance 2
  • Tech & AI News 4
  • Web Development 19
  • Wordpress Plugins 1
CoreGamix — Full-Stack Engineering & Developer ToolsCoreGamix — Full-Stack Engineering & Developer Tools

contact

support@coregamix.com

© 2026 CoreGamix. All Rights Reserved.  |  About  |  Privacy Policy  |  Terms of Use  |  Contact

Back to top