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
 Origin Forum
 Extracting data from sheets in workbook
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

leonardo.a027

Argentina
9 Posts

Posted - 01/18/2017 :  12:54:08 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi!
I am trying to extract data from a specific column and row of all worksheets in a specific workbook. I want to put the value of the specific cells in a new sheet in a new book, each value has to be identified with the name of the worksheet.
So far I have tried this:

doc -e LB
{
  int j=1;
  if (%H == "Book1")
    {
    loop(ii,1,page.nlayers) 
       {
        string str = wks.name$;
        [book2](sheet1)!2[j] = [%H]$(ii)!2[2];
        [book2](sheet1)!1[j] = str;
        j++;
      }
    }
}

But when I run it, nothing happens in the new book and new sheet that I previously created.
It'e been a long time trying to solve this.

Hideo Fujii

USA
1582 Posts

Posted - 01/18/2017 :  2:27:45 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi leonardo.a027,

The main problem in your code is that the notation, "[Book]Sheet!Column" is not an operational entity
such as for assignment, but for defining the range, mainly used in the Range declaration or sometime
as an argument of an x-function. Keeping this in mind, the following code should work:
////////////////////////////////////////////
doc -e LB
{
  int j=1;
  if (%H == "Book1")
    {
    loop(ii,1,page.nlayers) 
       {
        string str = wks.name$;
        range iw21=[book2]sheet1!1;
        range iw22=[book2]sheet1!2;
        range iw12= [%H]$(ii)!2;
        iw22[j] = iw12[2];
        iw21[j]$ = str$;
        j++;
      }
    }
}
////////////////////////////////////////////

Hope this helps.

--Hideo Fujii
OriginLab
Go to Top of Page

leonardo.a027

Argentina
9 Posts

Posted - 01/18/2017 :  2:41:47 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Hideo.
Thanks a lot for the help.
There's only one problem:
When I run the code, the output is:

Sheet4	1
Sheet4	2
Sheet4	3
Sheet4	4

As you can see the name of the sheets are all the same and they should be: Sheet1, Sheet2, Sheet3 and Sheet4.
I am not sure where's the problem.
Thanks again :).
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 01/18/2017 :  2:50:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi leonardo.a027,

You need to specify which sheet (=layer), So, in the first line of the loop block, you can use:
  string str = layer$(ii).name$;
instead of:
  string str = wks.name$;
Works?

--Hideo Fujii
Originlab
Go to Top of Page

leonardo.a027

Argentina
9 Posts

Posted - 01/18/2017 :  2:57:05 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks a lot Hideo!
Now it works just fine :)!
Go to Top of Page

Nornimices

1 Posts

Posted - 02/16/2017 :  09:20:25 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I am not sure about it.
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