Re: Reading Native Excel files
- To: mathgroup at smc.vnet.net
- Subject: [mg15057] Re: Reading Native Excel files
- From: tgayley at mcs.net (Todd Gayley)
- Date: Wed, 9 Dec 1998 04:12:37 -0500
- Organization: MCSNet Services
- References: <742vdo$mq3@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On 2 Dec 1998 03:57:28 -0500, "Barthelet, Luc" <lucb at ea.com> 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] Luc, 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 Mathematica. 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 Mathematica. 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 Out[3]= 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 (www.episoft.com). --Todd Gayley