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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 SetCell function and multiple variable types

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
jweinber Posted - 08/11/2005 : 11:34:00 AM
Origin Version (Select Help-->About Origin): 7.5
Operating System: XP

Hi, I'm trying to write my first origin c code and I'm having a problem. I am trying to combine a whole bunch of different worksheets (all in the same folder in project explorer) onto one worksheet.

I started by copying the first worksheet, so that I would have the correct designations and formats for the columns, and then just wanted to write out the cells for all the rest of the worksheets. All numerical values are being copied just fine, but the text values are not, I just get a - for all those fields.

I'm sure there is a more elegant way to write the code, but this is what I have done: Can setcell not change the cast for the third parameter back and forth?

Thanks for any help/suggestions!

Jennifer


// Combine selected worksheets (from the active folder in project explorer) into one worksheet.

void CombineWks()

{

StringArray sa;

GetWksList(sa);

Worksheet wks;
Worksheet SummaryWks;
int nRows=0;
int rows;
int col;


for(int i=0;i<sa.GetSize();i++) {

wks.Attach(sa[i]);

if (i==0) {
SummaryWks.CreateCopy(wks);
}
else {
nRows +=wks.GetNumRows();
}
}
ASSERT(SummaryWks.AppendRows(nRows));

for (i=0; i<sa.GetSize();i++) {
wks.Attach(sa[i]);
if (i==0) {
nRows=wks.GetNumRows();
}
else {
for (rows=0; rows<wks.GetNumRows();rows++) {

for (col=0;col<wks.GetNumCols(); col++) {

SummaryWks.SetCell(nRows, col, wks.Cell(rows,col));
}
nRows++;
}
}
}


SummaryWks.GetPage().Refresh(TRUE);

}

3   L A T E S T    R E P L I E S    (Newest First)
easwar Posted - 08/11/2005 : 12:57:26 PM
Hi Jennifer,

I see that earlier you posted in general forum and you are working with the PFM report worksheets?

I see that with the PFM report sheets, the column type is set to Numeric for columns that contain numbers such as peak centroid and other columns are either Text or Text&Numeric.

So one option is to check in the code what is the column type for the cell that you are copying - you know the col index and so can declare a col object with that and check the GetType() property - and then switch in your code based on what type it is?

Easwar
OriginLab


jweinber Posted - 08/11/2005 : 12:18:34 PM
Thanks. Is there a function that will read either a double or a string? I have both types in my worksheets that I am trying to copy, or would the best thing be to use an OR statement?

Thanks!
Jennifer
easwar Posted - 08/11/2005 : 11:47:56 AM
Hi Jennifer,

The problem is not with SetCell, which is overloaded and can handle both double and string, but with the argument that you pass to it.

You are using
SummaryWks.SetCell(nRows, col, wks.Cell(rows,col));

where the wks.Cell() method assumes what you are getting is double. To get string there is a wks.TCell() method.

Easwar
OriginLab



The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000