cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Mathcad 15 & Excel 2003

cairo-2
1-Visitor

Mathcad 15 & Excel 2003

Hi everyone,

I have a question about compatibilities between Mathcad and Excel :

I wrote a mathcad file with Mathcad15, where I use the function READEXCEL.

It works fine when I use my PC, with Windows7, Mathcad 15, Excel 2007 (.xlsx).

But it failed when I use a PC with Windows XP, Mathcad 15, Excel 2003 (.xls) : the function readexcel returns "corrupted data" when pointing to the .xls file ; the problem is : the application have to be used with the "WindowsXP, mathcad15 and excel 2003" configuration (because it's the client configuration).

Is the add-in for excel could fixe the problem in that way ??

Thank you all for your time and response,

Cécile

12 REPLIES 12
jsheehan
12-Amethyst
(To:cairo-2)

Hi Cecile

For 2003 Excel files in Mathcad 15 use the READFILE function with the "excel" file type.

For 2007 excel files in Mathcad 15 use the READEXCEL function

Good luck

John

Hi John and thank you for your answer.

I already tried Readfile, but I have almost ten sheets in one excel workbook.

I couldn't figure out how to specify the name of the sheets with the Readfile function.

Is there a way to do that?

Another lead was to do "Insert/File Input" (cf. thread http://communities.ptc.com/message/60487#60487) but I have to read the files dynamically so I can't do it following that solution.

Any idea ?

Thanks again,

Cécile

Have you tried using a scripted component? I have passed many over the last few years.

Mike

This should do the trick. I also have a component which will automatically find the Excel worksheet names if that would be of any help.

Mike

Thank you all for your answers !

I'll try two way :

- save the workbooks, with the extension .xlsx (fileformat :=51, if I'm right...) ; but I'm worried if it just changes the extension but not really the format... so if it doesn't work properly, I'll try :

- a script based on yours, Mike ; and I'll try a WriteExcel function following this script, too.

Mike, I've already have a script which scan the workbooks in the directory and the sheets in the workbooks, but thanks !

I'll tell you the conclusions,

Cécile

I'll try two way :

- save the workbooks, with the extension .xlsx (fileformat :=51, if I'm right...) ; but I'm worried if it just changes the extension but not really the format... so if it doesn't work properly, I'll try :

- a script based on yours, Mike ; and I'll try a WriteExcel function following this script, too.

Changing the extension will not work.

The WriteExcel function has also been written with script.

Mike

VladimirN
24-Ruby II
(To:cairo-2)

Hello!

cecile airo wrote:

But it failed when I use a PC with Windows XP, Mathcad 15, Excel 2003 (.xls) : the function readexcel returns "corrupted data" when pointing to the .xls file ; the problem is : the application have to be used with the "WindowsXP, mathcad15 and excel 2003" configuration (because it's the client configuration).

You need to use the following: in main menu select "Insert" -> "Component" -> "Microsoft Excel" (to specify an Excel worksheet, use the command ("SheetN!", where "N" - number one of the sheets in your Excel file)):

Pic_1.png

Pic_2.png

Pic_3.png

Pic_4.png

The problem with this approach is that the Excel worksheet becomes redundant and cannot be changed via Excel, so if further data is required a new worksheet will have to loaded.

Also, you will be increasing the size of the Mathcad file because you are holding all the Excel worksheets inside Mathcad.

A decent workaround though.

Mike

Just and FYI ... These issues have been fixed in Mathcad Prime1.0. You can specify the sheet number on both read and write Excel.

Do you mean the sheet number can be specified in Prime 1.0 for Excel 2003 worksheets?

Mike

Yes Mike. READEXCEL reads 2003 and 2007.

From online help,

Excel Data Files

There are two functions that are used to read from, or write to Excel files:

READEXCEL("file", [range, [emptyfill, [blankrows]]])—Returns a matrix from a defined range in an Excel worksheet.
WRITEEXCEL("file", M, [rows, [cols]])—Writes matrix M to the named Excel file.
Note

Remember that in order to execute, an expression in a Mathcad worksheet must be an assignment or a request for evaluation, as in:

Image

or

Image

Note

These functions support both XLS and XLSX file extensions.

Arguments

file is a string containing the filename or the full pathname and filename. You must include the XLS or XLSX file extension, for example, "heat.xlsx". Non-absolute pathnames are relative to the current working directory.
range is a string containing the cell range to read. You can specify the range in one of the following forms:
"Sheet1!A1:B3" specifying the worksheet name, the top left cell, and the bottom right cell. "Sheet1!A1" reads a single cell. "Sheet1" reads the entire worksheet.
"[1]A1:B3" specifying the worksheet number, the top left cell, and the bottom right cell. "[1]A1" reads a single cell. "[1]" reads the entire worksheet.

Cheers for the info John, good to know that Prime has improved compatibility with Excel.

Mike

Announcements

Top Tags