MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Reading Native Excel files

On 2 Dec 1998 03:57:28 -0500, "Barthelet, Luc" <lucb at> wrote:

>Did anyone write a notebook to read native Excel files in Mathematica?
>(*.xls under Windows)
>So far I have always forced the users to save the excel files as text
>files. It works fine, except it requires an extra step and therefore an
>extra opportunity for a human error.
>I have used Mathlink for Excel in the past and I do not want to use it
>for solving this since the whole point of it is to not require
>mathematica on those user machines.

[DISCLAIMER: I have a financial interest in sales of the product
mentioned herein]


The newly available Mathematica Link for Excel (not to be confused with
the old product "MathLink for Excel") provides a Mathematica function,
ReadExcel, that lets you read native Excel files directly into

You say that you have used MathLink for Excel in the past for this, but
although MathLink for Excel lets you share data with a Mathematica
kernel, it provides nothing like this ability to read Excel files into

Here is a sample of how you use the ReadExcel function. This is a
Mathematica function--it does not require Excel to be running, or even
installed, on a user's machine.

In[1]:= <<Excel`ReadExcel`

In[2]:= ?ReadExcel

ReadExcel["filename", "sheetname", {{row1, col1}, {row2, col2}}] reads
the specified range from the given sheet in the given Excel file. Row
and column specifications are integers, starting at 1. You can also use
Excel-type notation for the range:
    ReadExcel["filename", "sheetname", "A1:B2"],
    ReadExcel["filename", "sheetname", "R1C1:R2C2"],
    ReadExcel["filename", "sheetname", {"A1", "B2"}],
    ReadExcel["filename", "sheetname", {"R1C1", "R2C2"}].

In[3]:=  ReadExcel["d:\\test.xls", "Solver", "a1:f6"] // TableForm


Month           Q1         Q2         Q3          Q4         Total

Seasonality     0.9        1.1        0.8         1.2        Null

Units Sold      3591.55    4389.68    3192.49     4788.74    15962.5

Sales Revenue   143662.    175587.    127700.     191549.    638498.

Cost of Sales   89788.8    109742.    79812.3     119718.    399061.

Gross Margin    53873.3    65845.1    47887.4     71831.1    239437.

(It looks nicer in a fixed-width font.)

Mathematica Link for Excel is available from WRI or directly from
Episoft (

--Todd Gayley

  • Prev by Date: Re: FileManipulation
  • Next by Date: Re: strange graphics behavior
  • Previous by thread: RE: Reading Native Excel files
  • Next by thread: RE: [Q] Factoring arrays