-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathTableType.js
94 lines (91 loc) · 3.06 KB
/
TableType.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
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
function setTablePrePost(spec){
var colFeats = spec.colFeats;
var matrix = spec.matrix;
var tableType = spec.tableType;
var range = spec.range;
var tableCaption = spec.tableCaption;
var tableLabel = spec.tableLabel;
var tablePlacementSpecifier = spec.tablePlacementSpecifier;
var pre_table = '';
var post_table = '';
var counterstart = 0;
if (tableType=="longtable"){
var continue_next = getNextPageContinue(range.offset(range.getNumRows(), 0).getDisplayValue());
var continue_previous = getPreviousPageContinue(range.offset(range.getNumRows()+1, 0).getDisplayValue());
var mcol_width = String(colFeats.replace(/\|/g, '').length);
counterstart = 1;
pre_table += "\\begin{longtable}";
pre_table += "{" + colFeats + "}\r\n";
if(tableCaption){
pre_table += "\\caption{" + tableCaption + "}\\\\ \\hline\r\n";
pre_table += "\\label{tab:" + tableLabel + "}\r\n";
}
for(c=0;c<matrix[0].length;c++)
{
pre_table += matrix[0][c].pvalue;
}
pre_table += "\\\\ \r\n";
pre_table += "\\hline\r\n";
pre_table += "\\endfirsthead\r\n";
pre_table += "\\multicolumn{" + mcol_width +"}{c}%\r\n";
pre_table += continue_previous;
pre_table += "\\hline\r\n";
for(c=0;c<matrix[0].length;c++)
{
pre_table += matrix[0][c].pvalue;
}
pre_table += "\\\\ \r\n";
pre_table += "\\hline\r\n";
pre_table += "\\endhead\r\n";
pre_table += "\\hline \\multicolumn{" + mcol_width +"}"+continue_next;
pre_table += "\\endfoot\r\n";
pre_table += "\\hline\r\n";
pre_table += "\\endlastfoot\r\n";
pre_table += "\\hline\r\n";
post_table+= "\\end{longtable}\r\n";
}
else if (tableType=="tabular"){
pre_table += "\\begin{tabular}";
pre_table += "{" + colFeats + "}\r\n";
post_table+= "\\end{tabular}\r\n";
}
else if (tableType=="tabularx"){
pre_table += "\\begin{tabularx}";
pre_table += "{\\textwidth}";
pre_table += "{" + colFeats + "}\r\n";
post_table += "\\end{tabularx}\r\n";
}
else if (tableType=="table/tabular"){
pre_table += "\\begin{table}" + tablePlacementSpecifier + "\r\n";
pre_table += "\\centering\r\n";
pre_table += "\\begin{tabular}";
pre_table += "{" + colFeats + "}\r\n";
post_table+= "\\end{tabular}\r\n";
if(tableCaption){
post_table += "\\caption{" + tableCaption + "}\r\n";
post_table += "\\label{tab:" + tableLabel + "}\r\n";
}
post_table+= "\\end{table}\r\n";
}
else if (tableType=="table/tabularx"){
pre_table += "\\begin{table}" + tablePlacementSpecifier + "\r\n";
pre_table += "\\centering\r\n";
pre_table += "\\begin{tabularx}";
pre_table += "{\\textwidth}";
pre_table += "{" + colFeats + "}\r\n";
post_table += "\\end{tabularx}\r\n";
if(tableCaption){
post_table += "\\caption{" + tableCaption + "}\r\n";
post_table += "\\label{tab:" + tableLabel + "}\r\n";
}
post_table+= "\\end{table}\r\n";
}
else{
getTableTypeError(tableType);
}
return {
pre_table: pre_table,
post_table: post_table,
counterstart: counterstart
};
}