-
Notifications
You must be signed in to change notification settings - Fork 6
/
Create Manual String.js
55 lines (47 loc) · 1.43 KB
/
Create Manual String.js
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
function create_manual_string(spec) {
// Get the arguments from object spec
var range = spec.range;
var matrix = spec.matrix;
var colFeats = spec.colFeats;
var new_range = range.offset(-1, range.getNumColumns() , range.getNumRows()+1 , 1)
var new_range_value = new_range.getValues();
var manualColSpec = spec.manualColSpec;
var tableType = spec.tableType;
var tableCaption = spec.tableCaption;
var tableLabel = spec.tableLabel;
var tablePlacementSpecifier = spec.tablePlacementSpecifier;
var counterstart = 0;
var output = '';
var colAlign = '';
if(manualColSpec !== ''){
// Use users specification in case the cell above the table corner is
// not empty
colAlign = manualColSpec;
} else {
colAlign = columns_align(colFeats);
};
var prepost = setTablePrePost({
colFeats: colAlign,
range: range,
matrix: matrix,
tableType: tableType,
tableCaption: tableCaption,
tableLabel: tableLabel,
tablePlacementSpecifier: tablePlacementSpecifier,
});
counterstart = prepost.counterstart;
output+=prepost.pre_table;
// Add user specified commands (e.g. \hline) before the tabular rows
output += new_range_value[0][0] + '\r\n';
var i,j;
for(i=counterstart;i<matrix.length;i++)
{
for(j=0;j<matrix[i].length;j++)
{
output+=matrix[i][j].pvalue;
}
output+='\\\\' + new_range_value[i+1][0] + '\r\n';
}
output+=prepost.post_table;
return output;
}