origin CWord文档下载推荐.docx

上传人:b****8 文档编号:22691035 上传时间:2023-02-05 格式:DOCX 页数:12 大小:17.35KB
下载 相关 举报
origin CWord文档下载推荐.docx_第1页
第1页 / 共12页
origin CWord文档下载推荐.docx_第2页
第2页 / 共12页
origin CWord文档下载推荐.docx_第3页
第3页 / 共12页
origin CWord文档下载推荐.docx_第4页
第4页 / 共12页
origin CWord文档下载推荐.docx_第5页
第5页 / 共12页
点击查看更多>>
下载资源
资源描述

origin CWord文档下载推荐.docx

《origin CWord文档下载推荐.docx》由会员分享,可在线阅读,更多相关《origin CWord文档下载推荐.docx(12页珍藏版)》请在冰豆网上搜索。

origin CWord文档下载推荐.docx

}

}

ModifyNumericDataset

voidModifyNumericDataset()

if(wks&

&

wks.GetNumCols()>

=2)//tomakesureactivewindowisWorksheetandatleastexisttwocolumns

DataRangedr;

dr.Add(wks,0,"

X"

);

dr.Add(wks,1,"

vectorvA,vB;

dr.GetData(&

vA,0);

vB,1);

//sortthewholeworksheetbycolumnAwithascending

vector<

uint>

vnIndeces;

vA.Sort(SORT_ASCENDING,TRUE,vnIndeces);

//sortcolumnAandreturnedorderindeces

vB.Reorder(vnIndeces);

//reordercolumnBbycolumnAindeces

dr.SetData(vA,false,0);

dr.SetData(vB,false,1);

AccessOneNumericCell

voidAccessNumericData(intnRow=0,intnCol=0)

if(!

wks)

return;

doubledd=wks.Cell(nRow,nCol);

out_double("

Theoriginaldatais"

dd);

dd=100;

wks.SetCell(nRow,nCol,dd);

Themodifieddatais"

PutLargeDatasettoWorksheet

InordertokeepOriginCfunctionmoreefficientonputtingthelargedatasettoworksheet,forexample5000columns,needtodolikethestepsbelow.

▪Preparethecolumnsandrowsbeforeputintodatatoworksheet.

▪Use 

Worksheet:

:

SetSize,notuse 

AddCol 

tosetsize.

▪Setsizeonanemptyworksheet,meansnocolumn,sinceneedtochecktheshortnameoftheexistedcolumnstoavoidduplicatenamewhenaddnewcolumn.Thischeckmaycostmanytimes.Canuse 

while(wks.DeleteCol(0));

toremoveallcolumns.

▪Putdatatoworksheetcolumnbybuffer, 

DataObject:

GetInternalDataBuffer.

▪KeepCodeBuilderclosewhenrunningfunctiontosetsizeandputbackdatatoworksheet.

Seefollowingexamplecodes:

voidPutLargeDataset(introws=100,intcols=500)

//prepareworksheetsize

Worksheetwks;

wks.Create("

Origin"

while(wks.DeleteCol(0));

wks.SetSize(rows,cols);

//putdatasettoworksheetcolumnonebyone

col.SetFormat(OKCOLTYPE_NUMERIC);

col.SetInternalData(FSI_SHORT);

col.SetUpperBound(rows-1);

//indexoflastrow,0offset

int 

nElementSize;

uint 

nNum;

LPVOID 

pData=col.GetInternalDataBuffer(&

nElementSize,&

nNum);

short*psBuff=(short*)pData;

//OCloopisstillslow,butyoumightpassthispointertoyourDLL

//formuchfastermanipulation,herewejustshowthatthepointerworks

for(intii=0;

ii<

rows;

ii++,psBuff++)

*psBuff=(ii+1)*(col.GetIndex()+1);

col.ReleaseBuffer();

//doNOTremembertocallthis

String

Get/PutStringArray

voidAccessStringArray()

if(wks)

intnFormat=col.GetFormat();

if(OKCOLTYPE_TEXT==nFormat||OKCOLTYPE_TEXT_NUMERIC==nFormat)

string>

vstr;

col.GetStringArray(vstr);

DWORDdwOptions=SORT_ASCENDING|SORT_CASE_SENSITIVE;

vstr.Sort(dwOptions);

//ascendingsortwithcasesensitive

col.PutStringArray(vstr);

//putbacksortedstringarraytocolumn

AccessOneStringCell

voidAccessString(intnRow=0,intnCol=0)

stringstrVal;

wks.GetCell(nRow,nCol,strVal);

out_str(strVal);

strVal="

Thisisanexample!

"

;

wks.SetCell(nRow,nCol,strVal);

Columncol=wks.Columns(nCol);

col.SetWidth(-1);

//-1tosetthewidthtothelargestcellinthecolumn. 

DateandTime

voidAccessDateTimeData(intnColIndex)

Columncol(wks,nColIndex);

col)

//findoutthesmallestdate

if(OKCOLTYPE_DATE==col.GetFormat()||OKCOLTYPE_TIME==col.GetFormat())

vector&

//returntheJuliandatevalue

if(vec.GetSize()!

=0)

vec.Sort();

Thesmallestdateis 

%s\n"

get_date_str(vec[0],LDF_LONG));

MissingValue

voidfill_with_missing()

//getactiveworksheet

if(!

wks)

out_str("

Theactiveworksheetnotexist!

dr.Add("

wks,0,0,-1,-1);

//thewholeworksheet

dr.Replace(0,NANUM,WKSREPL_TEST_EQUAL);

//replacebymissing,missing=NANUM

Datasetds(wks,0);

//datasetattachedtocolumn1

ds=NANUM;

//clearcolumn1

Category:

WorkingwithData(Examples)

GetNumberofColumnsandRows

Thisexampleshowshowtogetthenumberofcolumnsandrowsinaworksheet

voidwks_get_cols_and_rows_num_ex()

WorksheetPagewp;

wp.Create("

//Getthefirstworksheetoftheworkbook

Worksheetwks(wp.Layers(0));

//Getthenumberofrowsandcolumns

intnRows=wks.GetNumRows();

intnCols=wks.GetNumCols();

Thenumberoftherowsin 

%sis:

%d\n"

wks.GetName(),nRows);

Thenumberofthecolumnsin 

wks.GetName(),nCols);

SetNumberofColumnsandRows

Thisexampleshowshowtosetthenumberofcolumnsandrowsinaworksheet

voidwks_set_cols_and_rows_num_ex()

//Setthenumberofrowsandcolumns

intnRows=50;

intnCols=5;

wks.SetSize(nRows,nCols))

Failedtosetsizeof 

%s!

\n"

wks.GetName());

AddColumn

Thisexampleshowshowtoaddcolumntothespecifiedworksheet

voidwks_add_col_ex()

stringstrColName;

//Addanewcolumnnamed"

NewCol"

iftherealreadyhasacolumnnamedNewCol,willautoenumeratenamewithnumberandputnametostrColName.

intiCol=wks.AddCol("

strColName);

if(iCol>

=0)

Newcolumnaddedatindex 

%d,name 

iCol,strColName);

DeleteColumn

Thisexampleshowshowtodeleteacolumnintheworksheet

voidwks_delete_col_ex()

//Deletethefirstcolumnoftheworksheet

if(wks.DeleteCol(0))

Successfuldeletecolumn\n"

else

Failedtodeletecolumn\n"

InsertColumn

Thisexampleshowshowtoinsertacolumnintheworksheet

voidwks_insert_col_ex()

Worksheetwks(wp.GetName());

intnPos=0;

//Settheinsertpositionasthefirstcolumn

stringstrColName="

NewInsert"

//Settheinsertcolumnnameto"

stringstrColCreated;

wks.InsertCol(nPos,strColName,strColCreated))

Failedtoinsertcolumn\n"

Newcolumninsertnamed 

strColCreated);

SetLargeSize

InordertokeepOriginCfunctionmoreefficientonsettingthelargenumberofcolumnsorrowsinworksheet,forexample5000columns,needtodolikethestepsbelow.

▪DoSetSizeonanemptyworksheet,meansnocolumn,sinceneedtochecktheshortnameoftheexistedcolumnstoavoidduplicatenamewhenaddnewcolumn.Thischeckmaycostmanytimes.Canuse 

▪KeepCodeBuilderclosewhenrunningfunctiontosetsize.

voidwks_set_large_size_ex(introws=100,intcols=5000)

//delallcolumns

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > PPT模板 > 其它模板

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1