Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
8b6fdd8b
Commit
8b6fdd8b
authored
Jan 19, 2017
by
konovalovsergey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add getTypeInfo for additional NumFormat info
parent
505662ae
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
55 deletions
+75
-55
cell/model/Workbook.js
cell/model/Workbook.js
+6
-0
common/NumFormat.js
common/NumFormat.js
+69
-55
No files found.
cell/model/Workbook.js
View file @
8b6fdd8b
...
@@ -5146,6 +5146,9 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){
...
@@ -5146,6 +5146,9 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){
Cell
.
prototype
.
getNumFormatType
=
function
(){
Cell
.
prototype
.
getNumFormatType
=
function
(){
return
this
.
getNumFormat
().
getType
();
return
this
.
getNumFormat
().
getType
();
};
};
Cell
.
prototype
.
getNumFormatTypeInfo
=
function
(){
return
this
.
getNumFormat
().
getTypeInfo
();
};
Cell
.
prototype
.
moveHor
=
function
(
val
){
Cell
.
prototype
.
moveHor
=
function
(
val
){
this
.
nCol
+=
val
;
this
.
nCol
+=
val
;
};
};
...
@@ -6548,6 +6551,9 @@ Range.prototype._foreachNoEmpty=function(action, excludeHiddenRows){
...
@@ -6548,6 +6551,9 @@ Range.prototype._foreachNoEmpty=function(action, excludeHiddenRows){
Range
.
prototype
.
getNumFormatType
=
function
(){
Range
.
prototype
.
getNumFormatType
=
function
(){
return
this
.
getNumFormat
().
getType
();
return
this
.
getNumFormat
().
getType
();
};
};
Range
.
prototype
.
getNumFormatTypeInfo
=
function
(){
return
this
.
getNumFormat
().
getTypeInfo
();
};
// Узнаем отличается ли шрифт (размер и гарнитура) в ячейке от шрифта в строке
// Узнаем отличается ли шрифт (размер и гарнитура) в ячейке от шрифта в строке
Range
.
prototype
.
isNotDefaultFont
=
function
()
{
Range
.
prototype
.
isNotDefaultFont
=
function
()
{
// Получаем фонт ячейки
// Получаем фонт ячейки
...
...
common/NumFormat.js
View file @
8b6fdd8b
...
@@ -79,6 +79,9 @@ var SignType = {Positive: 1, Negative: 2, Null:3};
...
@@ -79,6 +79,9 @@ var SignType = {Positive: 1, Negative: 2, Null:3};
var
gc_nMaxDigCount
=
15
;
//Максимальное число знаков точности
var
gc_nMaxDigCount
=
15
;
//Максимальное число знаков точности
var
gc_nMaxDigCountView
=
11
;
//Максимальное число знаков в ячейке
var
gc_nMaxDigCountView
=
11
;
//Максимальное число знаков в ячейке
var
gc_nMaxMantissa
=
Math
.
pow
(
10
,
gc_nMaxDigCount
);
var
gc_nMaxMantissa
=
Math
.
pow
(
10
,
gc_nMaxDigCount
);
var
gc_aTimeFormats
=
[
'
[$-F400]h:mm:ss AM/PM
'
,
'
h:mm;@
'
,
'
h:mm AM/PM;@
'
,
'
h:mm:ss;@
'
,
'
h:mm:ss AM/PM;@
'
,
'
mm:ss.0;@
'
,
'
[h]:mm:ss;@
'
];
var
gc_aFractionFormats
=
[
'
# ?/?
'
,
'
# ??/??
'
,
'
# ???/???
'
,
'
# ?/2
'
,
'
# ?/4
'
,
'
# ?/8
'
,
'
# ??/16
'
,
'
# ?/10
'
,
'
# ??/100
'
];
var
NumComporationOperators
=
var
NumComporationOperators
=
{
{
...
@@ -280,8 +283,6 @@ function NumFormat(bAddMinusIfNes)
...
@@ -280,8 +283,6 @@ function NumFormat(bAddMinusIfNes)
this
.
bSlash
=
false
;
this
.
bSlash
=
false
;
this
.
bWhole
=
false
;
this
.
bWhole
=
false
;
this
.
bCurrency
=
false
;
this
.
bCurrency
=
false
;
this
.
bNumber
=
false
;
this
.
bInteger
=
false
;
this
.
bRepeat
=
false
;
this
.
bRepeat
=
false
;
this
.
Color
=
-
1
;
this
.
Color
=
-
1
;
this
.
ComporationOperator
=
null
;
this
.
ComporationOperator
=
null
;
...
@@ -1368,10 +1369,12 @@ NumFormat.prototype =
...
@@ -1368,10 +1369,12 @@ NumFormat.prototype =
sText
+=
item
.
val
;
sText
+=
item
.
val
;
}
else
if
(
numFormat_Bracket
==
item
.
type
)
{
}
else
if
(
numFormat_Bracket
==
item
.
type
)
{
if
(
null
!=
item
.
CurrencyString
)
{
if
(
null
!=
item
.
CurrencyString
)
{
this
.
bCurrency
=
true
;
sText
+=
item
.
CurrencyString
;
sText
+=
item
.
CurrencyString
;
}
}
if
(
null
!=
item
.
Lid
)
{
if
(
null
!=
item
.
Lid
)
{
this
.
LCID
=
parseInt
(
item
.
Lid
,
16
);
//Excel sometimes add 0x10000(0x442 and 0x10442)
this
.
LCID
=
parseInt
(
item
.
Lid
,
16
)
&
0xFFFF
;
}
}
}
}
else
if
(
numFormat_DecimalPoint
==
item
.
type
)
{
else
if
(
numFormat_DecimalPoint
==
item
.
type
)
{
...
@@ -1388,15 +1391,6 @@ NumFormat.prototype =
...
@@ -1388,15 +1391,6 @@ NumFormat.prototype =
}
}
}
}
}
}
var
rxNumber
=
new
RegExp
(
"
^[0#?]+(
"
+
escapeRegExp
(
gc_sFormatDecimalPoint
)
+
"
[0#?]+)?$
"
);
var
match
=
this
.
formatString
.
match
(
rxNumber
);
if
(
null
!=
match
)
{
if
(
null
!=
match
[
1
])
{
this
.
bNumber
=
true
;
}
else
{
this
.
bInteger
=
true
;
}
}
}
}
}
}
return
this
.
valid
;
return
this
.
valid
;
...
@@ -1432,8 +1426,7 @@ NumFormat.prototype =
...
@@ -1432,8 +1426,7 @@ NumFormat.prototype =
format
:
function
(
number
,
nValType
,
dDigitsCount
,
cultureInfo
,
bChart
)
format
:
function
(
number
,
nValType
,
dDigitsCount
,
cultureInfo
,
bChart
)
{
{
if
(
null
!=
this
.
LCID
)
{
if
(
null
!=
this
.
LCID
)
{
//Excel sometimes add 0x10000(0x442 and 0x10442)
cultureInfo
=
g_aCultureInfos
[
this
.
LCID
];
cultureInfo
=
g_aCultureInfos
[
this
.
LCID
&
0xFFFF
];
}
}
if
(
null
==
cultureInfo
)
if
(
null
==
cultureInfo
)
cultureInfo
=
g_oDefaultCultureInfo
;
cultureInfo
=
g_oDefaultCultureInfo
;
...
@@ -1987,37 +1980,12 @@ NumFormat.prototype =
...
@@ -1987,37 +1980,12 @@ NumFormat.prototype =
output
.
format
=
res
;
output
.
format
=
res
;
return
true
;
return
true
;
},
},
getType
:
function
()
getFormatCellsInfo
:
function
()
{
{
var
info
=
new
Asc
.
asc_CFormatCellsInfo
();
var
nType
=
c_oAscNumFormatType
.
Custom
;
info
.
asc_setDecimalPlaces
(
this
.
aFracFormat
.
length
);
if
(
this
.
isGeneral
())
info
.
asc_setSeparator
(
this
.
bThousandSep
);
nType
=
c_oAscNumFormatType
.
General
;
info
.
asc_setSymbol
(
this
.
LCID
);
else
if
(
this
.
bTextFormat
)
return
info
;
nType
=
c_oAscNumFormatType
.
Text
;
else
if
(
this
.
bDateTime
)
{
if
(
this
.
bDate
)
nType
=
c_oAscNumFormatType
.
Date
;
else
nType
=
c_oAscNumFormatType
.
Time
;
}
else
if
(
this
.
nPercent
>
0
)
nType
=
c_oAscNumFormatType
.
Percent
;
else
if
(
this
.
bScientific
)
nType
=
c_oAscNumFormatType
.
Scientific
;
else
if
(
this
.
bCurrency
){
if
(
this
.
bRepeat
)
nType
=
c_oAscNumFormatType
.
Accounting
;
else
nType
=
c_oAscNumFormatType
.
Currency
;
}
else
if
(
this
.
bSlash
)
nType
=
c_oAscNumFormatType
.
Fraction
;
else
if
(
this
.
bNumber
)
nType
=
c_oAscNumFormatType
.
Number
;
else
if
(
this
.
bInteger
)
nType
=
c_oAscNumFormatType
.
Integer
;
return
nType
;
},
},
isGeneral
:
function
()
{
isGeneral
:
function
()
{
return
1
==
this
.
aRawFormat
.
length
&&
numFormat_General
==
this
.
aRawFormat
[
0
].
type
;
return
1
==
this
.
aRawFormat
.
length
&&
numFormat_General
==
this
.
aRawFormat
[
0
].
type
;
...
@@ -2435,13 +2403,60 @@ CellFormat.prototype =
...
@@ -2435,13 +2403,60 @@ CellFormat.prototype =
}
}
return
result
;
return
result
;
},
},
getType
:
function
()
getType
:
function
()
{
{
return
this
.
getTypeInfo
().
type
;
if
(
null
!=
this
.
oPositiveFormat
)
},
return
this
.
oPositiveFormat
.
getType
();
getTypeInfo
:
function
()
{
else
if
(
null
!=
this
.
aComporationFormats
&&
this
.
aComporationFormats
.
length
>
0
)
var
info
;
return
this
.
aComporationFormats
[
0
].
getType
();
if
(
null
!=
this
.
oPositiveFormat
)
{
return
c_oAscNumFormatType
.
General
;
info
=
this
.
oPositiveFormat
.
getFormatCellsInfo
();
info
.
asc_setType
(
this
.
_getType
(
this
.
oPositiveFormat
));
}
else
if
(
null
!=
this
.
aComporationFormats
&&
this
.
aComporationFormats
.
length
>
0
)
{
info
=
this
.
aComporationFormats
[
0
].
getFormatCellsInfo
();
info
.
asc_setType
(
this
.
_getType
(
this
.
aComporationFormats
[
0
]));
}
else
{
info
=
new
Asc
.
asc_CFormatCellsInfo
();
info
.
asc_setType
(
c_oAscNumFormatType
.
General
);
info
.
asc_setDecimalPlaces
(
0
);
info
.
asc_setSeparator
(
false
);
info
.
asc_setSymbol
(
null
);
}
return
info
;
},
_getType
:
function
(
format
)
{
var
nType
=
c_oAscNumFormatType
.
Custom
;
if
(
format
.
isGeneral
())
{
nType
=
c_oAscNumFormatType
.
General
;
}
else
if
(
format
.
bDateTime
)
{
if
(
format
.
bDate
)
{
nType
=
c_oAscNumFormatType
.
Date
;
}
else
{
nType
=
c_oAscNumFormatType
.
Time
;
}
}
else
if
(
format
.
bCurrency
)
{
if
(
format
.
bRepeat
)
{
nType
=
c_oAscNumFormatType
.
Accounting
;
}
else
{
nType
=
c_oAscNumFormatType
.
Currency
;
}
}
else
{
var
info
=
format
.
getFormatCellsInfo
();
var
types
=
[
c_oAscNumFormatType
.
Text
,
c_oAscNumFormatType
.
Percent
,
c_oAscNumFormatType
.
Scientific
,
c_oAscNumFormatType
.
Number
,
c_oAscNumFormatType
.
Fraction
];
for
(
var
i
=
0
;
i
<
types
.
length
;
++
i
)
{
var
type
=
types
[
i
];
info
.
asc_setType
(
type
);
var
formats
=
getFormatCells
(
info
);
if
(
-
1
!=
formats
.
indexOf
(
this
.
sFormat
))
{
nType
=
type
;
break
;
}
}
}
return
nType
;
}
}
};
};
var
oDecodeGeneralFormatCache
=
{};
var
oDecodeGeneralFormatCache
=
{};
...
@@ -4067,8 +4082,7 @@ function setCurrentCultureInfo(val) {
...
@@ -4067,8 +4082,7 @@ function setCurrentCultureInfo(val) {
res
.
push
(
locale
+
'
d
'
+
separator
+
'
mmm
'
+
separator
+
'
yyyy;@
'
);
res
.
push
(
locale
+
'
d
'
+
separator
+
'
mmm
'
+
separator
+
'
yyyy;@
'
);
}
}
}
else
if
(
Asc
.
c_oAscNumFormatType
.
Time
===
info
.
type
)
{
}
else
if
(
Asc
.
c_oAscNumFormatType
.
Time
===
info
.
type
)
{
res
.
push
(
'
[$-F400]h:mm:ss AM/PM
'
,
'
h:mm;@
'
,
'
h:mm AM/PM;@
'
,
'
h:mm:ss;@
'
,
'
h:mm:ss AM/PM;@
'
,
'
mm:ss.0;@
'
,
res
=
gc_aTimeFormats
;
'
[h]:mm:ss;@
'
);
}
else
if
(
Asc
.
c_oAscNumFormatType
.
Percent
===
info
.
type
)
{
}
else
if
(
Asc
.
c_oAscNumFormatType
.
Percent
===
info
.
type
)
{
format
=
'
0
'
;
format
=
'
0
'
;
if
(
info
.
decimalPlaces
>
0
)
{
if
(
info
.
decimalPlaces
>
0
)
{
...
@@ -4077,7 +4091,7 @@ function setCurrentCultureInfo(val) {
...
@@ -4077,7 +4091,7 @@ function setCurrentCultureInfo(val) {
format
+=
'
%
'
;
format
+=
'
%
'
;
res
.
push
(
format
);
res
.
push
(
format
);
}
else
if
(
Asc
.
c_oAscNumFormatType
.
Fraction
===
info
.
type
)
{
}
else
if
(
Asc
.
c_oAscNumFormatType
.
Fraction
===
info
.
type
)
{
res
.
push
(
'
# ?/?
'
,
'
# ??/??
'
,
'
# ???/???
'
,
'
# ?/2
'
,
'
# ?/4
'
,
'
# ?/8
'
,
'
# ??/16
'
,
'
# ?/10
'
,
'
# ??/100
'
)
;
res
=
gc_aFractionFormats
;
}
else
if
(
Asc
.
c_oAscNumFormatType
.
Scientific
===
info
.
type
)
{
}
else
if
(
Asc
.
c_oAscNumFormatType
.
Scientific
===
info
.
type
)
{
format
=
'
0.
'
+
'
0
'
.
repeat
(
info
.
decimalPlaces
)
+
'
E+00
'
;
format
=
'
0.
'
+
'
0
'
.
repeat
(
info
.
decimalPlaces
)
+
'
E+00
'
;
res
.
push
(
format
);
res
.
push
(
format
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment