首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在OriginLab专业版中添加/导入工作表

如何在OriginLab专业版中添加/导入工作表
EN

Stack Overflow用户
提问于 2017-05-08 01:15:38
回答 1查看 83关注 0票数 0

现在,我知道如何将"SQL-Data“导入到工作表中。

但我不能将"SQL-Data“附加到现有的工作表中,因为它会随着时间的推移而增长。

代码语言:javascript
复制
//Pseudo Code
1. maxID <-- getMaxValueOutOfColumnId()
2. import via SQL --> "SELECT * FROM table WHERE ID > maxID"
3. append the result set as rows to the sheet maxID came from.

我找到了关于导入东西的教程,但它们没有附加SQL-Data。

EN

回答 1

Stack Overflow用户

发布于 2017-05-18 15:42:25

对于未来的访问者,我会发布我想出的解决方案。

代码语言:javascript
复制
// In general
1. have a book with 2 sheets named test_data and data_import
2. put a click button on sheet data_import
3. open the buttons preferences and activate tab "programming"
4. write yourself some LabTalk code in the small code-field

/* 1. Step */
range ra = "test_data"!col(A);
int max_id = max(ra);

/* 2. Step */
string strSQL$="SELECT * FROM table WHERE id > ($(max_id))";
string strConn$="<CONNECTION STRING GOES HERE>";
dbEdit change conn:=strConn$ sql:=strSQL$;
dbImport;
dbEdit remove;

/* 3. Step */
range ra = "test_data"!;          // sheet to extend with imported data
range rb = "data_import"!;        // helper sheet as cache
wrcopy iw:=rb c1:=1 r1:=1         // append cached data on sheet test_data
       ow:=ra dc1:=1 dr1:=ra.maxRows+1;

/* 4. Step - cleaning up */
int cols = rb.ncols;              // number of columns
for(int ii = cols; ii > 0; ii -= 1) {
   delete wcol($(ii));            // delete all columns form data_import
};
for(int ii = cols; ii > 0; ii -= 1) {
   rb.addCol();                   // append new columns
};
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43834409

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档