# 基本用法

esProc提供了函数clipboard，可实现剪贴板的基本用法。下面用“各科前3名的学生”为例进行说明。

Excel中处理前的数据如下，其中A列是学生姓名，B-D列分别是数学、英语、物理成绩。

| | A | B | C | D |
| 1 | name | math | english | physics |
| 2 | lily | 97 | 100 | 99 |
| 3 | Joshua | 100 | 99 | 100 |
| 4 | Sarah | 98 | 99 | 96 |
| 5 | Bertram | 94 | 95 | 85 |
| 6 | Paula | 91 | 88 | 91 |
| 7 | Sophia | 92 | 81 | 76 |
| 8 | Ben | 87 | 80 | 76 |
| 9 | Ruth | 92 | 91 | 87 |
| 10 | Pag | 95 | 87 | 87 |

| | A | B |
| 1 | =clipboard().import@t() | /从剪切板读取数据 |
| 2 | =A1.top(-3;math).(name) | /math前3名 |
| 3 | =A1.top(-3;english).(name) | |
| 4 | =A1.top(-3;physics).(name) | |
| 5 | =join@p(A2;A3;A4).export() | /拼成二维表，转成字串 |
| 6 | =clipboard(A5) | | /向剪切板写数据 |
| | | | |

| | A | B | C | D |
| | … | … | … | … |
| 10 | Pag | 95 | 87 | 87 |
| 11 | | Joshua | Lily | Joshua |
| 12 | | Sarah | Sarah | Lily |
| 13 | | lily | Joshua | Sarah |

# 随意编辑脚本

| | A | B | C |
| 1 | =clipboard@e().import@t() | /从剪切板读取数据 | |
| 2 | =A1.top(-3;math).(name) | =A1.top(-3;english).(name) | =A1.top(-3;physics).(name) |
| 3 | =join@p(A2;B2;B3).export() | /拼成二维表，转成字串 | |
| 4 | =clipboard(A3) | /向剪切板写数据 | |

# 多个结果片区

clipboard(…)只能返回一个结果，但有些较复杂的运算可能需要返回多个结果，这该怎么办呢？

| | A | B | C |
| 1 | =clipboard@e().import@t() | 从剪切板获取数据 | |
| 2 | =A1.top(-3;math).(name) | =A1.top(-3;english).(name) | =A1.top(-3;physics).(name) |
| 3 | =join@p(A2;B2;C2) | 片区1：各科前3名 | |
| 4 | =A1.derive(sum(math,english,physics):subtotal) | 每个人的总分 | |
| 5 | =A4.derive(t=subtotal,A4.select(subtotal>t):beforeMe) | 排在本人前面的学生 | |
| 6 | =A5.new(beforeMe.top(3;subtotal).(name).concat(“>”):target) | 片区2：最近3名学生 | |

| | A | B | C | D |
| 1 | name | math | english | physics |
| 2 | Lily | 97 | 100 | 99 |
| 3 | Joshua | 100 | 99 | 100 |
| 4 | Sarah | 98 | 99 | 96 |
| 5 | Bertram | 94 | 95 | 85 |
| 6 | Paula | 91 | 88 | 91 |
| 7 | Sophia | 92 | 81 | 76 |
| 8 | Ben | 87 | 80 | 76 |
| 9 | Ruth | 92 | 91 | 87 |
| 10 | Pag | 95 | 87 | 87 |
| 11 | | Joshua | lily | Joshua |
| 12 | | Sarah | Sarah | lily |
| 13 | | lily | Joshua | Sarah |

| | A | B | C | D | E |
| 1 | name | math | english | physics | Target |
| 2 | Lily | 97 | 100 | 99 | Joshua |
| 3 | Joshua | 100 | 99 | 100 | |
| 4 | Sarah | 98 | 99 | 96 | lily>Joshua |
| 5 | Bertram | 94 | 95 | 85 | Sarah>lily>Joshua |
| 6 | Paula | 91 | 88 | 91 | Bertram>Sarah>lily |
| 7 | Sophia | 92 | 81 | 76 | Pag>Ruth>Paula |
| 8 | Ben | 87 | 80 | 76 | Sophia>Pag>Ruth |
| 9 | Ruth | 92 | 91 | 87 | Bertram>Sarah>lily |
| 10 | Pag | 95 | 87 | 87 | Ruth>Paula>Bertram |
| 11 | | Joshua | lily | Joshua | |
| 12 | | Sarah | Sarah | lily | |
| 13 | | lily | Joshua | Sarah | |

# 多个源片区

Excel中有两个sheet，订单明细和员工名单，其中订单明细如下：

| | A | B | C | D | E |
| 1 | OrderID | Client | SellerId | Amount | OrderDate |
| 2 | 1 | WVF Vip | 1 | 440 | 2014-11-03 |
| 3 | 2 | UFS Com | 1 | 1863 | 2015-01-01 |
| 4 | 3 | SWFR | 2 | 1813 | 2014-11-01 |
| 5 | 4 | JFS Pep | 2 | 671 | 2015-01-01 |
| 6 | 5 | DSG | 1 | 3730 | 2015-01-01 |
| 7 | 6 | JFE | 1 | 1445 | 2015-01-01 |
| 8 | 7 | OLF | 3 | 625 | 2015-01-01 |
| 9 | 8 | PAER | 3 | 2490 | 2015-01-01 |

| | A | B | C | D | E | F | G |
| 1 | EId | State | Dept | Name | Gender | Salary | Birthday |
| 2 | 2 | New York | Marketing | Ashley | F | 11001 | 1980-07-19 |
| 3 | 3 | New Mexico | Sales | Rachel | F | 9000 | 1970-12-17 |
| 4 | 4 | Texas | HR | Emily | F | 7000 | 1985-03-07 |
| 5 | 5 | Texas | R&D | Ashley | F | 16000 | 1975-05-13 |
| 6 | 6 | California | Sales | Matthew | M | 11000 | 1984-07-07 |
| 7 | 7 | Illinois | Sales | Alexis | F | 9000 | 1972-08-16 |
| 8 | 8 | California | Marketing | Megan | F | 11000 | 1979-04-19 |
| 9 | 1 | Texas | HR | Victoria | F | 3000 | 1983-12-07 |

| | A | B | C |
| 1 | OrderID Client… | =A1.import@t() | /order list |
| 2 | EId State… | =A2.import@t() | /employee list |
| 3 | =B1.switch(SellerId,B2:EId) | | /Join with EId |
| 4 | =A3.select(OrderDate>=after(date(now()),days*-1)|| depts.pos(SellerId.Dept)) | | /Search data |
| 5 | =A4.new(OrderID,OrderDate,Amount,SellerId.Name:Name,SellerId.Dept:Dept) | | /return fields needed |

(=￣ω￣=)··· 暂无内容！

15

0

2

4