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中文论坛
 Origin 中文论坛 (Chinese Origin Forum)
 Origin C: 创建一个5列5行的工作表
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

vickey

14 Posts

Posted - 05/13/2016 :  03:00:45 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin C 第一弹: 创建一个5列5行的工作表


void create_worksheet()
{
WorksheetPage wp; // 分配工作簿空间给wp
wp.Create("Origin"); // 创建一个基于Origin内置模板的工作簿
//拿到第一个工作簿
Worksheet wks(wp.Layers(0));
//设置行位50 列为5
int nRows = 50;
int nCols = 5;
if(!wks.SetSize(nRows, nCols))
{
printf("Failed to set size of %s!\n", wks.GetName());
}
}
在Origin中,要对列或者行进行操作,必须先找到列和行所在的工作表,工作表所在的工作簿,这样按照工作簿-》工作表-》列,行=》单元格这个层级次序进行调用就OK了。


相关参考:


Page类下面包含的Member:
http://originlab.com/doc/OriginC/ref/Page-Class


WorksheetPage:工作页
http://originlab.com/doc/OriginC/ref/WorksheetPage-WorksheetPage


Create: 创建图页,矩阵页,工作簿页以及布局页
http://originlab.com/doc/OriginC/ref/Page-Create


第一次写,大家多多包涵,会一次比一次写的好的!


代码有错误或者大家有自己的想法和使用心得,求指出和分享!


谢谢!

HeatSink

China
1 Posts

Posted - 06/12/2016 :  06:44:10 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by vickey
Origin C 第一弹: 创建一个5列5行的工作表


楼主有没有涉及用OC获取和设置Parameter或User Parameter等标题行的数据?
英文版里翻遍了,都是用LT,但LT太变态,跟机器码差不多。。。

Vouloir, c'est pouvoir.
Go to Top of Page

Sophy

China
Posts

Posted - 06/12/2016 :  10:15:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply

void	test_labels()
{
	Worksheet wks = Project.ActiveLayer();
	if ( wks )
	{
		Grid gg;
		gg.Attach(wks);
		vector<int> vnTypes;
		gg.GetShowLabels(vnTypes);
		//show it only when it is hidden, then later set labels for the first column
#define	CHECK_ADD_LABEL(_Type) if ( !gg.IsLabelsShown(_Type) )vnTypes.Add(_Type);
		CHECK_ADD_LABEL(RCLT_PARAM);
		CHECK_ADD_LABEL(RCLT_PARAM);
		CHECK_ADD_LABEL(RCLT_UDL);
		gg.SetShowLabels(vnTypes);
		
		Column colA(wks, 0);
		colA.SetExtendedLabel("User Comments", RCLT_COMMENT);
		colA.SetExtendedLabel("Parameter", RCLT_PARAM);
		colA.SetExtendedLabel("Parameter 2", RCLT_PARAM + 1);
		colA.SetExtendedLabel("User Defined Parameter", RCLT_UDL);

		return;
	}
}

Edited by - Sophy on 06/12/2016 10:16:24 PM
Go to Top of Page

Echo_Chu

China
Posts

Posted - 06/12/2016 :  10:56:02 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
建议你去看看Origin C的帮助, 上面有Origin C Programming Guide和各种example. 例如下面这页, 正好对应你问的问题的example.

http://www.originlab.com/doc/OriginC/examples/Column-Name-and-Labels
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