forked from suranofsky/tech-services-g-sheets-addon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sampleData.gs
188 lines (139 loc) · 9.11 KB
/
sampleData.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
//WHEN THE "Click to initialize sample tabs" BUTTON IS CLICKED
//THIS FUNCTION INSERTS TABS THAT CONTAIN SAMPLE SEARCH DATA &
//SAMPLE SEARCH CRITERIA
function initSampleData(form) {
var rand = Math.floor((Math.random() * 1000) + 1);
var ui = SpreadsheetApp.getUi();
var spreadsheet = SpreadsheetApp.getActive();
settingsSheet = spreadsheet.insertSheet();
try {
settingsSheet.setName("Sample Search Criteria");
}
catch(err) {
//IN CASE TAB WITH THIS NAME ALREADY EXISTS
settingsSheet.setName("Search Criteria Sample" + rand);
}
var outputRange = settingsSheet.getRange(1, 1, 37, 8);
//ADD THE SEARCH CRITERIA
outputRange.getCell(1,1).setValue("search:").setFontWeight("bold");
outputRange.getCell(2,1).setValue("holdings=LYU");
outputRange.getCell(2,2).setValue("<-- set your OCLC Symbol here or clear this cell if you don't want it to look for your own holdings");
outputRange.getCell(3,1).setValue("040=dlc").setBackground("#D6EAF8");
outputRange.getCell(3,2).setValue("040$b=eng").setBackground("#D6EAF8");
outputRange.getCell(3,3).setValue("336$b=txt").setBackground("#D6EAF8");
outputRange.getCell(3,4).setValue("337$b=n").setBackground("#D6EAF8");
outputRange.getCell(3,5).setValue("338$b=nc").setBackground("#D6EAF8");
outputRange.getCell(3,6).setBackground("#D6EAF8");
outputRange.getCell(3,7).setBackground("#D6EAF8");
outputRange.getCell(3,8).setValue("<-- all must be true for a 'match'");
outputRange.getCell(4,1).setValue("042=pcc").setBackground("#D6EAF8");
outputRange.getCell(4,2).setValue("040$b=eng").setBackground("#D6EAF8");
outputRange.getCell(4,3).setValue("336$b=txt").setBackground("#D6EAF8");
outputRange.getCell(4,4).setValue("337$b=n").setBackground("#D6EAF8");
outputRange.getCell(4,5).setValue("338$b=nc").setBackground("#D6EAF8");
outputRange.getCell(4,6).setBackground("#D6EAF8");
outputRange.getCell(4,7).setBackground("#D6EAF8");
outputRange.getCell(4,8).setValue("<-- all must be true for a 'match'");
outputRange.getCell(5,1).setValue("336$b=txt").setBackground("#D6EAF8");
outputRange.getCell(5,2).setValue("337$b=c").setBackground("#D6EAF8");
outputRange.getCell(5,3).setValue("338$b=cr").setBackground("#D6EAF8");
outputRange.getCell(5,4).setBackground("#D6EAF8");
outputRange.getCell(5,5).setBackground("#D6EAF8");
outputRange.getCell(5,6).setBackground("#D6EAF8");
outputRange.getCell(5,7).setBackground("#D6EAF8");
outputRange.getCell(5,8).setValue("<-- all must be true for a 'match'");
outputRange.getCell(6,1).setBackground("#D6EAF8");
outputRange.getCell(6,2).setBackground("#D6EAF8");
outputRange.getCell(6,3).setBackground("#D6EAF8");
outputRange.getCell(6,4).setBackground("#D6EAF8");
outputRange.getCell(6,5).setBackground("#D6EAF8");
outputRange.getCell(6,6).setBackground("#D6EAF8");
outputRange.getCell(6,7).setBackground("#D6EAF8");
outputRange.getCell(7,1).setBackground("#D6EAF8");
outputRange.getCell(7,2).setBackground("#D6EAF8");
outputRange.getCell(7,3).setBackground("#D6EAF8");
outputRange.getCell(7,4).setBackground("#D6EAF8");
outputRange.getCell(7,5).setBackground("#D6EAF8");
outputRange.getCell(7,6).setBackground("#D6EAF8");
outputRange.getCell(7,7).setBackground("#D6EAF8");
outputRange.getCell(8,1).setBackground("#D6EAF8");
outputRange.getCell(8,2).setBackground("#D6EAF8");
outputRange.getCell(8,3).setBackground("#D6EAF8");
outputRange.getCell(8,4).setBackground("#D6EAF8");
outputRange.getCell(8,5).setBackground("#D6EAF8");
outputRange.getCell(8,6).setBackground("#D6EAF8");
outputRange.getCell(8,7).setBackground("#D6EAF8");
//ADD THE RETURN CRITERIA
outputRange.getCell(11,1).setValue("fields:").setFontWeight("bold");
outputRange.getCell(11,2).setValue("starting column:").setFontWeight("bold");
outputRange.getCell(12,1).setNumberFormat("@").setValue("001").setBackground("#D6EAF8");
outputRange.getCell(12,2).setNumberFormat("@").setBackground("#D6EAF8").setValue("4");
outputRange.getCell(12,3).setValue("Cols 1,2,3 are used for ISBN, LCCN, 'local record found indicator'. 082:092:050 notation will print first field found.");
outputRange.getCell(13,1).setValue("245$a").setBackground("#D6EAF8");
//outputRange.getCell(13,2).setNumberFormat("@").setBackground("#D6EAF8").setValue("5");
outputRange.getCell(14,1).setValue("245$b").setBackground("#D6EAF8");
//outputRange.getCell(14,2).setNumberFormat("@").setBackground("#D6EAF8").setValue("6");
outputRange.getCell(15,1).setValue("245$c").setBackground("#D6EAF8");
//outputRange.getCell(15,2).setNumberFormat("@").setBackground("#D6EAF8").setValue("7");
outputRange.getCell(16,1).setNumberFormat("@").setBackground("#D6EAF8").setValue("082:092:050");
//outputRange.getCell(16,2).setNumberFormat("@").setBackground("#D6EAF8").setValue("8");
//outputRange.getCell(16,3).setValue("<-- will print first field found");
outputRange.getCell(17,1).setNumberFormat("@").setBackground("#D6EAF8").setValue("050:090");
//outputRange.getCell(17,2).setNumberFormat("@").setBackground("#D6EAF8").setValue("9");
outputRange.getCell(18,1).setNumberFormat("@").setBackground("#D6EAF8");
//outputRange.getCell(18,2).setNumberFormat("@").setBackground("#D6EAF8");
outputRange.getCell(19,1).setNumberFormat("@").setBackground("#D6EAF8");
//outputRange.getCell(19,2).setNumberFormat("@").setBackground("#D6EAF8");
outputRange.getCell(20,1).setNumberFormat("@").setBackground("#D6EAF8");
//outputRange.getCell(20,2).setNumberFormat("@").setBackground("#D6EAF8");
outputRange.getCell(21,1).setNumberFormat("@").setBackground("#D6EAF8");
//outputRange.getCell(21,2).setNumberFormat("@").setBackground("#D6EAF8");
outputRange.getCell(22,1).setNumberFormat("@").setBackground("#D6EAF8");
//outputRange.getCell(22,2).setNumberFormat("@").setBackground("#D6EAF8");
outputRange.getCell(23,1).setNumberFormat("@").setBackground("#D6EAF8");
//outputRange.getCell(23,2).setNumberFormat("@").setBackground("#D6EAF8");
outputRange.getCell(24,1).setNumberFormat("@").setBackground("#D6EAF8");
//outputRange.getCell(24,2).setNumberFormat("@").setBackground("#D6EAF8");
outputRange.getCell(25,1).setNumberFormat("@").setBackground("#D6EAF8");
//outputRange.getCell(25,2).setNumberFormat("@").setBackground("#D6EAF8");
outputRange.getCell(26,1).setNumberFormat("@").setBackground("#D6EAF8");
//outputRange.getCell(26,2).setNumberFormat("@").setBackground("#D6EAF8");
outputRange.getCell(27,1).setNumberFormat("@").setBackground("#D6EAF8");
//outputRange.getCell(27,2).setNumberFormat("@").setBackground("#D6EAF8");
outputRange.getCell(28,1).setNumberFormat("@").setBackground("#D6EAF8");
//outputRange.getCell(28,2).setNumberFormat("@").setBackground("#D6EAF8");
outputRange.getCell(29,1).setNumberFormat("@").setBackground("#D6EAF8");
//outputRange.getCell(29,2).setNumberFormat("@").setBackground("#D6EAF8");
outputRange.getCell(30,1).setNumberFormat("@").setBackground("#D6EAF8");
//outputRange.getCell(30,2).setNumberFormat("@").setBackground("#D6EAF8");
outputRange.getCell(31,1).setNumberFormat("@").setBackground("#D6EAF8");
//outputRange.getCell(31,2).setNumberFormat("@").setBackground("#D6EAF8");
outputRange.getCell(32,1).setNumberFormat("@").setBackground("#D6EAF8");
//outputRange.getCell(32,2).setNumberFormat("@").setBackground("#D6EAF8");
outputRange.getCell(33,1).setNumberFormat("@").setBackground("#D6EAF8");
//outputRange.getCell(33,2).setNumberFormat("@").setBackground("#D6EAF8");
outputRange.getCell(34,1).setNumberFormat("@").setBackground("#D6EAF8");
//outputRange.getCell(34,2).setNumberFormat("@").setBackground("#D6EAF8");
outputRange.getCell(35,1).setNumberFormat("@").setBackground("#D6EAF8");
//outputRange.getCell(35,2).setNumberFormat("@").setBackground("#D6EAF8");
outputRange.getCell(36,1).setNumberFormat("@").setBackground("#D6EAF8");
//outputRange.getCell(36,2).setNumberFormat("@").setBackground("#D6EAF8");
//CREATE SHEET WITH SAMPLE SEARCHES
settingsSheet = spreadsheet.insertSheet();
try {
settingsSheet.setName("Sample Searches");
}
catch(err) {
//IN CASE TAB WITH THIS NAME ALREADY EXISTS
settingsSheet.setName("Sample Searches" + rand);
}
var outputRange = settingsSheet.getRange(1, 1, 4, 4);
outputRange.getCell(1,1).setValue("ISBN").setFontWeight("bold");
outputRange.getCell(1,2).setValue("LCCN").setFontWeight("bold")
outputRange.getCell(1,3).setValue("local record indicator").setFontWeight("bold");
outputRange.getCell(1,4).setValue("<--script will populate this column");
outputRange.getCell(2,1).setNumberFormat("@").setValue("9781849763721");
outputRange.getCell(3,1).setNumberFormat("@").setValue("9780297178545");
outputRange.getCell(4,2).setNumberFormat("@").setValue("66-25377");
return getTabs();
}