Skip to content
Skip to content

Practical LLM operations guide · By Yes AI

Can a private LLM read spreadsheets and databases?

Published 5 min read

Document assistants are built to search prose: policies, contracts and manuals. A question like 'how many claims did we close in March' needs numbers from a table, which is a different problem. This guide explains the ways an LLM can work with structured data and the controls each one needs.

Quick answer

It can, though usually not by indexing the spreadsheet like a document. Text search over chunks of a table separates rows from their headers, and totals worked out by the model inside its answer are hard to check. The dependable approaches are to let the model write a query that your system runs with the user's permissions, to run code over an uploaded file, or to expose fixed reports as tools. Each returns calculated results that the model then explains.

Finance analyst in an Adelaide office comparing a printed spreadsheet with a laptop showing blurred tables

Why does document search struggle with tables?

Retrieval systems split files into chunks, turn each chunk into an embedding and fetch the closest matches to a question. That works for paragraphs. A spreadsheet chunk might hold rows 400 to 450 without the header row, so the model sees numbers without knowing which column they belong to. A question that needs a total across 3,000 rows cannot be answered from the handful of chunks a retriever returns. Some file search tools do not accept spreadsheets at all: OpenAI's file search lists formats such as .docx, .pdf, .pptx and .txt, and .xlsx and .csv do not appear in that list.

How does a model query a database safely?

In this pattern, often called text-to-SQL, the model receives descriptions of the tables and the user's question, and writes a query. Your application runs the query and passes the rows back for the model to explain. OpenAI's function calling guide describes this division: the model suggests a call, and your code executes it and returns the result. That split is where the safety controls go. Run queries with a read-only database account, limit which tables and views are visible, cap rows and run time, and log every query with the user who asked it.

Permissions belong in the database. Microsoft's row-level security for SQL Server and Azure SQL uses group membership or execution context to control which rows a query can return, so a regional manager's question only sees their region even if the generated query forgets to filter. Relying on the model to add the right WHERE clause is not a control.

When is running code over a file the better fit?

For one-off analysis of an exported file, a code execution tool can load the spreadsheet and calculate with real code. OpenAI's code interpreter, for example, lists .csv and .xlsx among its supported files, and self-hosted deployments can run an equivalent sandbox on their own infrastructure. The model writes and runs a short program, and the answer comes from the program's output, which you can inspect. This suits ad hoc questions about a report someone has exported. It suits live operational data poorly, because the file is a snapshot and the source system's permissions no longer apply once the export has been uploaded.

Are fixed reports simpler than open-ended queries?

Many structured-data questions are predictable: monthly totals, open items by owner, overdue invoices by customer. For these, build a small set of tested queries or report endpoints and give the model one tool for each, with parameters such as month or region. The model chooses the tool and fills in the parameters, and it never writes free-form SQL. You lose some flexibility. In return, the answers match the figures in your existing reports, which matters when finance staff or a board will compare them.

How do you keep the numbers in an answer trustworthy?

Even with correct data, the written explanation can introduce errors, for example by restating a total from memory or mixing up two periods. Design the answer so that a reader can check it against the source in a few seconds, and so that a wrong figure is easy to spot in review. The display rules below help with both. They also make feedback reports more useful, because staff can say which step went wrong.

  • Show the figure from the query result, not a number the model restated in its own words.
  • Display the query or report name and the time the data was read.
  • State the filters applied, such as date range and business unit.
  • Round only in presentation, after the calculation.
  • Refuse and explain when the question needs data the tools cannot reach.

How should you test structured-data answers?

Build a test set of questions with known answers taken from your existing reports. Include simple lookups, totals across periods, questions with no matching data, and questions a user should not be able to answer because of their role. Run each question as several different users to confirm that row-level permissions hold. Hypothetical example: a 40-question set might hold 15 lookups, 15 aggregations, 5 empty-result questions and 5 permission checks; these numbers are illustrative only. Rerun the set after any change to the schema, the model or the tool definitions.

Ways to answer from structured data

ApproachBest forMain riskKey control
Index the spreadsheet as textSmall reference tables such as a price listLost headers and incomplete totalsUse for reference tables only
Model writes queries (text-to-SQL)Open-ended questions on live dataWrong or over-broad queriesRead-only account, row-level security, query logging
Code execution over an uploaded fileOne-off analysis of an exportStale snapshot and lost source permissionsLimit who can upload and which files
Fixed reports exposed as toolsRepeated questions with agreed definitionsQuestions outside the report setTested queries and a clear refusal

Practical checklist

  • Structured-data questions are listed and classed as fixed reports or open-ended queries.
  • The database account used by the assistant is read-only and limited to approved views.
  • Row-level security, or an equivalent filter in the data layer, restricts results for each user.
  • Every generated query is logged with the user, time and row count.
  • Answers show the source query or report and the time the data was read.
  • The test set includes permission checks run as different users.

Common questions

Can we just upload our Excel files to the knowledge base?

You can, and small reference tables such as a price list or contact directory often work. Large or numeric sheets usually do not, because chunking separates rows from headers and the retriever returns only a few chunks. Some tools reject spreadsheets for file search altogether. Test a handful of real questions with known answers before relying on it.

Is text-to-SQL safe on a production database?

It can be, with controls in the database instead of in the prompt. Use a read-only account, expose curated views instead of raw tables, enforce row-level security, set query time and row limits, and log every query. Pointing it at a reporting replica means a heavy query cannot slow the production system that staff and customers rely on.

What about data in systems like Xero, Salesforce or SharePoint lists?

These systems expose APIs, and the same patterns apply. Give the model a tool that calls a specific endpoint with the user's own credentials or a tightly scoped service account, return the result, and have the model explain it. Avoid broad export-and-index copies of system data, which go stale and lose the source system's permissions.

Does a self-hosted model change any of this?

The patterns are the same. A self-hosted model can call tools and generate queries in the same way, and the database controls sit in your systems wherever the model runs. The difference is that query results, which may contain personal information, stay within your own infrastructure instead of passing through a hosted model provider.

Sources and further reading

Continue planning

Plan the checks before your next LLM release

Describe the task, source documents and people who will review the answers. We can discuss evaluation, access boundaries and a staged implementation. Keep confidential documents and access credentials out of this enquiry.