forked from sheetjs/sheetjs
tweaking general format
[ci skip]
This commit is contained in:
parent
30c8c4c071
commit
e1b753f797
4
ssf.js
4
ssf.js
@ -1,5 +1,5 @@
|
|||||||
/* ssf.js (C) 2013 SheetJS -- http://sheetjs.com */
|
/* ssf.js (C) 2013 SheetJS -- http://sheetjs.com */
|
||||||
var SSF;
|
var SSF = {};
|
||||||
(function(SSF){
|
(function(SSF){
|
||||||
String.prototype.reverse=function(){return this.split("").reverse().join("");};
|
String.prototype.reverse=function(){return this.split("").reverse().join("");};
|
||||||
var _strrev = function(x) { return String(x).reverse(); };
|
var _strrev = function(x) { return String(x).reverse(); };
|
||||||
@ -86,7 +86,7 @@ var frac = function(x, D, mixed) {
|
|||||||
var general_fmt = function(v) {
|
var general_fmt = function(v) {
|
||||||
if(typeof v === 'boolean') return v ? "TRUE" : "FALSE";
|
if(typeof v === 'boolean') return v ? "TRUE" : "FALSE";
|
||||||
if(typeof v === 'number') {
|
if(typeof v === 'number') {
|
||||||
return v.toString().substr(0,11);
|
return v.toPrecision(10).replace(/\.0*$/,"").replace(/\.(.*[^0])0*$/,".$1");
|
||||||
}
|
}
|
||||||
if(typeof v === 'string') return v;
|
if(typeof v === 'string') return v;
|
||||||
throw "unsupport value in General format: " + v;
|
throw "unsupport value in General format: " + v;
|
||||||
|
7
ssf.md
7
ssf.md
@ -134,11 +134,12 @@ Booleans are serialized in upper case:
|
|||||||
if(typeof v === 'boolean') return v ? "TRUE" : "FALSE";
|
if(typeof v === 'boolean') return v ? "TRUE" : "FALSE";
|
||||||
```
|
```
|
||||||
|
|
||||||
For numbers, try to display up to 11 digits of the number:
|
For numbers, try to display up to 11 digits of the number (the original code
|
||||||
|
`return v.toString().substr(0,11);` was not satisfactory in the case of 11 2/3)
|
||||||
|
|
||||||
```
|
```
|
||||||
if(typeof v === 'number') {
|
if(typeof v === 'number') {
|
||||||
return v.toString().substr(0,11);
|
return v.toPrecision(10).replace(/\.0*$/,"").replace(/\.(.*[^0])0*$/,".$1");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -737,7 +738,7 @@ var frac = function(x, D, mixed) {
|
|||||||
|
|
||||||
```js>tmp/00_header.js
|
```js>tmp/00_header.js
|
||||||
/* ssf.js (C) 2013 SheetJS -- http://sheetjs.com */
|
/* ssf.js (C) 2013 SheetJS -- http://sheetjs.com */
|
||||||
var SSF;
|
var SSF = {};
|
||||||
(function(SSF){
|
(function(SSF){
|
||||||
String.prototype.reverse=function(){return this.split("").reverse().join("");};
|
String.prototype.reverse=function(){return this.split("").reverse().join("");};
|
||||||
var _strrev = function(x) { return String(x).reverse(); };
|
var _strrev = function(x) { return String(x).reverse(); };
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ssf.js (C) 2013 SheetJS -- http://sheetjs.com */
|
/* ssf.js (C) 2013 SheetJS -- http://sheetjs.com */
|
||||||
var SSF;
|
var SSF = {};
|
||||||
(function(SSF){
|
(function(SSF){
|
||||||
String.prototype.reverse=function(){return this.split("").reverse().join("");};
|
String.prototype.reverse=function(){return this.split("").reverse().join("");};
|
||||||
var _strrev = function(x) { return String(x).reverse(); };
|
var _strrev = function(x) { return String(x).reverse(); };
|
||||||
@ -86,7 +86,7 @@ var frac = function(x, D, mixed) {
|
|||||||
var general_fmt = function(v) {
|
var general_fmt = function(v) {
|
||||||
if(typeof v === 'boolean') return v ? "TRUE" : "FALSE";
|
if(typeof v === 'boolean') return v ? "TRUE" : "FALSE";
|
||||||
if(typeof v === 'number') {
|
if(typeof v === 'number') {
|
||||||
return v.toString().substr(0,11);
|
return v.toPrecision(10).replace(/\.0*$/,"").replace(/\.(.*[^0])0*$/,".$1");
|
||||||
}
|
}
|
||||||
if(typeof v === 'string') return v;
|
if(typeof v === 'string') return v;
|
||||||
throw "unsupport value in General format: " + v;
|
throw "unsupport value in General format: " + v;
|
||||||
|
Loading…
Reference in New Issue
Block a user