The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 How to import Excel files as internal worksheet
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

wufengseu

China
Posts

Posted - 12/27/2007 :  11:08:48 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): Origin 8.0
Operating System:PC

Can somebody tell me how to import Excel files as internal Origin worksheet by Origin C Program. Great thanks!

Edited by - wufengseu on 12/27/2007 11:49:33 PM

cpyang

USA
1406 Posts

Posted - 12/27/2007 :  11:37:46 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can import the whole Excel book as a new book with code given in the OC page.h file:


void import_xls(string strFile)
{
WorksheetPage wp;
int nErr = wp.OpenExcel(XL_IMPORT, strFile);
if( wp )
{
Worksheet wks = wp.Layers();
printf("Opened [%s] as an Origin workbook (%s) with Sheet '%s' active", strFile, wp.GetName(), wks.GetName());
}
else
printf("Import Excel failed, error code = %d\n", nErr);
}



You can run by compiling this and from script window:


dlgfile g:=*.xls;import_xls fname$;

The drawback is that a new book is always created and all the sheets are imported. In the next service release (SR2), we are adding support to import selected sheets into existing book.

CP



Go to Top of Page

wufengseu

China
Posts

Posted - 12/28/2007 :  12:44:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for CPs detailed guidance.
While if one want to import large number of Excel files consecutively, it seems this method work does not work.
it may be settled by Origin C.

Furthermore, the Excel file produced by C program
can not be converted correctly, which does not appear in
the version of Origin 7.5.






Edited by - wufengseu on 12/28/2007 12:54:37 AM
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 12/28/2007 :  09:27:05 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You need to give more details on both issues.

1. how many Excel files are you trying to open and when does it start to fail? after 5 files? after 100 files?

2. Not converted correctly in what way? Can you send me one such Excel file to look at? You can send it to me at cp@originlab.com.

Origin75 opens Excel by COM and Excel must be installed on the same machine. Origin 8 still has this mechanism, and you can see if via drag and drop, but this mechanism is not yet connected to OC, and we can fix this in SR2.

CP


Go to Top of Page

wufengseu

China
Posts

Posted - 12/30/2007 :  10:44:36 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you again!

Resaving the Excel file produced by C actually can solve trouble

of STG_E_FILEALREADYEXISTS, attention the size of file expands

greatly from 4k to 15k.
Go to Top of Page

msarahan

USA
Posts

Posted - 02/02/2008 :  11:39:46 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi there,

System info: Origin 8 student version, SR 1.

I'm trying to import an excel file into an origin workbook. Doing a File->import excel works great, but only for the first sheet in the excel file. All the other sheets get their name on a sheet in the origin workbook, but they're totally empty. How can I import it so that all of the sheets get imported?

Being able to select which sheets to import, as mentioned above, will be an excellent feature.

I'm trying to plot data from more than one sheet, which only seems to be possible with origin sheets, not with excel workbooks. This seems like a pretty major flaw when combined with the inability to import all the sheets in a workbook...

My current solution is to use Origin 7.5 to import excel files as sheets, and use them from there. That doesn't seem right.

Any help will be greatly appreciated.

Thanks,
Mike
Go to Top of Page

wufengseu

China
Posts

Posted - 02/26/2008 :  03:00:25 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
My method is to directly drag the Excel files into Origin 7.5 Project and doing other operations in Origin 8.0.
I hope this may be helpful to you.

Edited by - wufengseu on 02/26/2008 03:03:37 AM
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000