-
Notifications
You must be signed in to change notification settings - Fork 6
/
Data.js
51 lines (50 loc) · 1.29 KB
/
Data.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
function datumToStr(obj){
var range = obj.range,
settingsArray = obj.settingsArray,
datumSettings = getDatumSettingsFromArray(settingsArray);
// Select between full precision and displayed values
if(datumSettings.getFullPrecision()){
var values=range.getValues();
}
else{
var values=range.getDisplayValues();
}
// Use a know separator or the user string
var separators = getDevSettings().getDataColSeparators();
if(separators.hasOwnProperty(datumSettings.getSep())){
var sep = separators[datumSettings.getSep()];
} else {
var sep = datumSettings.getSep()+'';
}
var str='';
var line='';
var rNum=range.getNumRows();
// Choose between column swap
if(datumSettings.getColumnSwap() === false){
var cNum=range.getNumColumns();
for(var r=0; r<rNum; r++)
{
line='';
for(var c=0; c<cNum; c++)
{
line+=values[r][c]+sep;
};
line=line.slice(0,-sep.length);
str+=line+'\r\n';
};
}
else{
var colNumStrings = datumSettings.getColumnSwap().split('c');
for(var r=0; r<rNum; r++)
{
line='';
for(var i=1;i<colNumStrings.length;i++)
{
line+=values[r][parseInt(colNumStrings[i])-1]+sep;
};
line=line.slice(0,-sep.length);
str+=line+'\r\n';
};
}
return str;
}