Skip to content
⌘K

Parse and Analyze Excel Spreadsheets with LlamaParse

In this example, learn how to use LlamaParse to parse Excel spreadsheets, and (optionally) use that as the basis for a RAG app that can answer questions about the data within the table.

For this example, we’ll be using a simple DCF template, which you can download here. Once you do, rename the file to dcf_template.xlsx.

Example Spreadsheet

At the end of this example, we will create a mini RAG app with LlamaIndex framework that can answer questions, using OpenAI. You can skip this part, or use another model provider

To get started, we’ll install llama-cloud and (optionally) llama-index-llms-openai:

!pip install 'llama-cloud>=1.0.0b3'
!pip install llama-index-llms-openai
import os
from getpass import getpass
os.environ["LLAMA_CLOUD_API_KEY"] = getpass("Llama Cloud API Key: ")
os.environ["OPENAI_API_KEY"] = getpass("OpenAI API Key: ")

Llama Cloud API Key: ·········· OpenAI API Key: ··········

Once you have your API keys, you can initialize your LlamaCloud client:

from llama_cloud import LlamaCloud, AsyncLlamaCloud
client = AsyncLlamaCloud()

Once you have LlamaParse set up, you can parse the example spreadsheet, which should result in the following output:

from llama_cloud.types.parsing_create_params import ProcessingOptions, ProcessingOptionsAutoModeConfiguration, ProcessingOptionsAutoModeConfigurationParsingConf
file_obj = await client.files.create(file="dcf_template.xlsx",
purpose="parse",)
result = await client.parsing.parse(tier="agentic",
version="latest",
file_id=file_obj.id,
expand=['markdown'],
processing_options=ProcessingOptions(
auto_mode_configuration=[ProcessingOptionsAutoModeConfiguration(
parsing_conf=ProcessingOptionsAutoModeConfigurationParsingConf(
high_res_ocr=True,
outlined_table_extraction=True,
adaptive_long_table=True,
)
)]
))
while result.job.status in ("PENDING", "RUNNING"):
print(f"Job status: {result.job.status}. Waiting...")
await asyncio.sleep(3)
result = await client.parsing.get(parse_job.id, expand=["markdown"])
print(result.markdown.pages[1].markdown)

Expected output:

Discounted Cash Flow Excel Template
Here is a simple discounted cash flow excel template for estimating your company value based on this income valuation approach
Instructions:
1) Fill out the two assumptions in yellow highlight
2) Fill in either the 5 year or 3 year weighted average figures in yellow highlight
Assumptions
Tax Rate20%
Discount Rate15%
5 Year Weighted Moving Average
Indication of Company Value$242,995.43
3 Year Weighted Moving Average
Indication of Company Value$158,651.07
5 Year Weighted Moving Average
Past YearsForecasted Future Years
Year 1Year 2Year 3Year 4Year 5Year 6Year 7Year 8Year 9Year 10Terminal Value
Pre-tax income50,000.0055,000.0045,000.0052,000.0060,000.00
Income Taxes10,000.0011,000.009,000.0010,400.0012,000.00
Net Income40,000.0044,000.0036,000.0041,600.0048,000.00
Depreciation Expense5,000.004,000.003,000.002,000.001,000.00
Capital Expenditures10,000.008,000.005,000.005,000.007,000.00
Debt Repayments5,000.005,000.005,000.005,000.005,000.00
Net Cash Flow20,000.0027,000.0023,000.0029,600.0035,000.0029,093.3329,817.7830,177.4830,469.2330,379.74287,188.00
Discounting Factor0.86960.75610.65750.57180.49720.4972
Present Value of Future Cash Flow25,298.5522,546.5219,842.1817,420.8815,104.10142,783.19
3 Year Weighted Moving Average
Past YearsForecasted Future Years
Year 1Year 2Year 3Year 4Year 5Year 6Terminal Value
Pre-tax income50,000.0055,000.0045,000.00
Income Taxes10,000.0011,000.009,000.00
Net Income40,000.0044,000.0036,000.00
Depreciation Expense5,000.004,000.003,000.00
Capital Expenditures10,000.008,000.005,000.00
Debt Repayments5,000.005,000.005,000.00
Net Cash Flow20,000.0027,000.0023,000.0023,833.3324,083.3323,819.44158,253.59
Discounting Factor0.86960.75610.65750.6575
Present Value of Future Cash Flow20,724.6418,210.4615,661.67104,054.30
Notes:
-We based this simple discounted cash flow excel model based on the weighted moving averages (5 year or 3 year) for simplicity, in case a constant growth rate cannot be easily determined.
-The factors such as Depreciation Expense, Capital Expense and Debt Repayments remain constant, so consider this when looking at the forecasted figures.
-For the terminal value constant growth rate, we make the assumption of the growth from the last forecasted year compared to the first forecasted year. Adjust in the formula as needed.

Now, you can create a system that is able to answer questions based on the context provided by the parsed excel spreadsheet. For this step, we’ll be using LlamaIndex. We start by configuring an LLM. In this case, we are using gpt-5:

from llama_index.llms.openai import OpenAI
llm = OpenAI(model="gpt-5-mini")

The easiest way to do this is to augment a prompt with the contents of the parsed spreadsheet:

from llama_index.core.llms import ChatMessage
llama_parse_documents = result.markdown.pages
query_str = "Tell me about the income taxes in the past years (year 3-5) for the 5 year WMA table"
context = "\n\n".join([doc.markdown for doc in llama_parse_documents])
messages = [
ChatMessage(
role="user",
content=f"Here is some context\n<context>{context}</context>\n\nAnswer the following question: {query_str}",
)
]
response = await llm.achat(messages)
print(response.message.content)

For the 5‑year WMA table, the income taxes for past years 3–5 are:

  • Year 3: $9,000.00
  • Year 4: $10,400.00
  • Year 5: $12,000.00

These values are 20% of the reported pre‑tax incomes for those years (Year 3: $45,000; Year 4: $52,000; Year 5: $60,000), matching the 20% tax rate in the assumptions. The taxes rise from $9k → $10.4k → $12k, reflecting the increase in pre‑tax income.

Expected output:

In the 5‑year WMA table the income tax amounts for past years 3–5 are:
- Year 3: $9,000.00
- Year 4: $10,400.00
- Year 5: $12,000.00
These equal 20% of the respective pre‑tax incomes (45,000; 52,000; 60,000), consistent with the 20% tax rate assumption. The taxes rise each year as pre‑tax income increases.