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
aadc52b5
Commit
aadc52b5
authored
Jan 16, 2017
by
konovalovsergey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asc_getFormatCells implementation
parent
bdc4855b
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
486 additions
and
246 deletions
+486
-246
cell/api.js
cell/api.js
+110
-3
cell/model/WorkbookElems.js
cell/model/WorkbookElems.js
+18
-240
common/NumFormat.js
common/NumFormat.js
+358
-3
No files found.
cell/api.js
View file @
aadc52b5
...
@@ -254,15 +254,122 @@ var editor;
...
@@ -254,15 +254,122 @@ var editor;
}
}
return
res
;
return
res
;
};
};
spreadsheet_api
.
prototype
.
asc_getFormatCells
=
function
(
info
)
{
spreadsheet_api
.
prototype
.
asc_getFormatCells
=
function
(
info
)
{
var
res
=
[];
if
(
info
)
{
var
format
;
var
i
;
var
cultureInfo
=
AscCommon
.
g_aCultureInfos
[
info
.
symbol
];
var
currency
=
!!
cultureInfo
;
if
(
Asc
.
c_oAscNumFormatType
.
General
===
info
.
type
)
{
res
.
push
(
AscCommon
.
g_cGeneralFormat
);
}
else
if
(
Asc
.
c_oAscNumFormatType
.
Number
===
info
.
type
)
{
var
numberFormat
=
AscCommon
.
getNumberFormatSimple
(
info
.
separator
,
info
.
decimalPlaces
);
res
.
push
(
numberFormat
);
res
.
push
(
numberFormat
+
'
;[Red]
'
+
numberFormat
);
res
.
push
(
AscCommon
.
getNumberFormat
(
cultureInfo
,
info
.
separator
,
info
.
decimalPlaces
,
false
));
res
.
push
(
AscCommon
.
getNumberFormat
(
cultureInfo
,
info
.
separator
,
info
.
decimalPlaces
,
true
));
}
else
if
(
Asc
.
c_oAscNumFormatType
.
Currency
===
info
.
type
)
{
res
.
push
(
AscCommon
.
getCurrencyFormatSimple2
(
cultureInfo
,
info
.
decimalPlaces
,
currency
,
false
));
res
.
push
(
AscCommon
.
getCurrencyFormatSimple2
(
cultureInfo
,
info
.
decimalPlaces
,
currency
,
true
));
res
.
push
(
AscCommon
.
getCurrencyFormatSimple
(
cultureInfo
,
info
.
decimalPlaces
,
currency
,
currency
,
false
));
res
.
push
(
AscCommon
.
getCurrencyFormatSimple
(
cultureInfo
,
info
.
decimalPlaces
,
currency
,
currency
,
true
));
}
else
if
(
Asc
.
c_oAscNumFormatType
.
Accounting
===
info
.
type
)
{
res
.
push
(
AscCommon
.
getCurrencyFormat
(
cultureInfo
,
info
.
decimalPlaces
,
currency
,
currency
));
}
else
if
(
Asc
.
c_oAscNumFormatType
.
Date
===
info
.
type
)
{
//todo locale dependence
if
(
info
.
symbol
==
AscCommon
.
g_oDefaultCultureInfo
.
LCID
)
{
res
.
push
(
AscCommon
.
getShortDateFormat
(
cultureInfo
));
res
.
push
(
'
[$-F800]dddd, mmmm dd, yyyy
'
);
}
res
.
push
(
AscCommon
.
getShortDateFormat2
(
1
,
1
,
0
,
cultureInfo
)
+
'
;@
'
);
res
.
push
(
AscCommon
.
getShortDateFormat2
(
1
,
1
,
2
,
cultureInfo
)
+
'
;@
'
);
res
.
push
(
AscCommon
.
getShortDateFormat2
(
2
,
2
,
2
,
cultureInfo
)
+
'
;@
'
);
res
.
push
(
AscCommon
.
getShortDateFormat2
(
1
,
1
,
4
,
cultureInfo
)
+
'
;@
'
);
res
.
push
(
AscCommon
.
getShortDateFormat2
(
1
,
1
,
2
,
cultureInfo
)
+
'
h:mm;@
'
);
res
.
push
(
'
[$-409]
'
+
AscCommon
.
getShortDateFormat2
(
1
,
1
,
2
,
cultureInfo
)
+
'
h:mm AM/PM;@
'
);
var
locale
=
AscCommon
.
getLocaleFormat
(
cultureInfo
,
false
);
res
.
push
(
locale
+
'
mmmmm;@
'
);
res
.
push
(
locale
+
'
mmmm d, yyyy;@
'
);
var
separators
=
[
'
-
'
,
'
/
'
,
'
'
];
for
(
i
=
0
;
i
<
separators
.
length
;
++
i
)
{
var
separator
=
separators
[
i
];
res
.
push
(
locale
+
'
d
'
+
separator
+
'
mmm;@
'
);
res
.
push
(
locale
+
'
d
'
+
separator
+
'
mmm
'
+
separator
+
'
yy;@
'
);
res
.
push
(
locale
+
'
dd
'
+
separator
+
'
mmm
'
+
separator
+
'
yy;@
'
);
res
.
push
(
locale
+
'
mmm
'
+
separator
+
'
yy;@
'
);
res
.
push
(
locale
+
'
mmmm
'
+
separator
+
'
yy;@
'
);
res
.
push
(
locale
+
'
mmmmm
'
+
separator
+
'
yy;@
'
);
res
.
push
(
locale
+
'
d
'
+
separator
+
'
mmm
'
+
separator
+
'
yyyy;@
'
);
}
}
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;@
'
,
'
[h]:mm:ss;@
'
);
}
else
if
(
Asc
.
c_oAscNumFormatType
.
Percent
===
info
.
type
)
{
format
=
'
0
'
;
if
(
info
.
decimalPlaces
>
0
)
{
format
+=
'
.
'
+
'
0
'
.
repeat
(
info
.
decimalPlaces
);
}
format
+=
'
%
'
;
res
.
push
(
format
);
}
else
if
(
Asc
.
c_oAscNumFormatType
.
Fraction
===
info
.
type
)
{
res
.
push
(
'
# ?/?
'
,
'
# ??/??
'
,
'
# ???/???
'
,
'
# ?/2
'
,
'
# ?/4
'
,
'
# ?/8
'
,
'
# ??/16
'
,
'
# ?/10
'
,
'
# ??/100
'
);
}
else
if
(
Asc
.
c_oAscNumFormatType
.
Scientific
===
info
.
type
)
{
format
=
'
0.
'
+
'
0
'
.
repeat
(
info
.
decimalPlaces
)
+
'
E+00
'
;
res
.
push
(
format
);
}
else
if
(
Asc
.
c_oAscNumFormatType
.
Text
===
info
.
type
)
{
res
.
push
(
'
@
'
);
}
else
if
(
Asc
.
c_oAscNumFormatType
.
Custom
===
info
.
type
)
{
for
(
i
=
0
;
i
<=
4
;
++
i
)
{
res
.
push
(
AscCommonExcel
.
aStandartNumFormats
[
i
]);
}
res
.
push
(
AscCommon
.
getCurrencyFormatSimple
(
null
,
0
,
false
,
false
,
false
));
res
.
push
(
AscCommon
.
getCurrencyFormatSimple
(
null
,
0
,
false
,
false
,
true
));
res
.
push
(
AscCommon
.
getCurrencyFormatSimple
(
null
,
2
,
false
,
false
,
false
));
res
.
push
(
AscCommon
.
getCurrencyFormatSimple
(
null
,
2
,
false
,
false
,
true
));
res
.
push
(
AscCommon
.
getCurrencyFormatSimple
(
null
,
0
,
true
,
false
,
false
));
res
.
push
(
AscCommon
.
getCurrencyFormatSimple
(
null
,
0
,
true
,
false
,
true
));
res
.
push
(
AscCommon
.
getCurrencyFormatSimple
(
null
,
2
,
true
,
false
,
false
));
res
.
push
(
AscCommon
.
getCurrencyFormatSimple
(
null
,
2
,
true
,
false
,
true
));
for
(
i
=
9
;
i
<=
13
;
++
i
)
{
res
.
push
(
AscCommonExcel
.
aStandartNumFormats
[
i
]);
}
res
.
push
(
AscCommon
.
getShortDateFormat
(
null
));
res
.
push
(
AscCommon
.
getShortDateMonthFormat
(
true
,
true
,
null
));
res
.
push
(
AscCommon
.
getShortDateMonthFormat
(
true
,
false
,
null
));
res
.
push
(
AscCommon
.
getShortDateMonthFormat
(
false
,
true
,
null
));
for
(
i
=
18
;
i
<=
21
;
++
i
)
{
res
.
push
(
AscCommonExcel
.
aStandartNumFormats
[
i
]);
}
res
.
push
(
AscCommon
.
getShortDateFormat
(
null
)
+
"
h:mm
"
);
for
(
i
=
45
;
i
<=
49
;
++
i
)
{
res
.
push
(
AscCommonExcel
.
aStandartNumFormats
[
i
]);
}
//todo add all used in workbook formats
}
else
{
res
.
push
(
AscCommon
.
g_cGeneralFormat
);
}
}
else
{
res
.
push
(
AscCommon
.
g_cGeneralFormat
);
res
.
push
(
'
0.00
'
);
res
.
push
(
AscCommon
.
getCurrencyFormatSimple2
(
null
,
2
,
true
,
false
));
res
.
push
(
AscCommon
.
getCurrencyFormat
(
null
,
2
,
true
,
true
));
res
.
push
(
AscCommon
.
getShortDateFormat
());
//todo F800 F400
res
.
push
(
'
[$-F800]dddd, mmmm dd, yyyy
'
);
res
.
push
(
'
[$-F400]h:mm:ss AM/PM
'
);
res
.
push
(
'
0.00%
'
);
res
.
push
(
'
# ?/?
'
);
res
.
push
(
'
@
'
);
}
return
res
;
};
};
spreadsheet_api
.
prototype
.
asc_getLocaleCurrency
=
function
(
val
)
{
spreadsheet_api
.
prototype
.
asc_getLocaleCurrency
=
function
(
val
)
{
var
cultureInfo
=
AscCommon
.
g_aCultureInfos
[
val
];
var
cultureInfo
=
AscCommon
.
g_aCultureInfos
[
val
];
if
(
!
cultureInfo
)
{
if
(
!
cultureInfo
)
{
cultureInfo
=
AscCommon
.
g_aCultureInfos
[
1033
];
cultureInfo
=
AscCommon
.
g_aCultureInfos
[
1033
];
}
}
return
AscCommonExcel
.
getCurrencyFormat
(
cultureInfo
,
true
,
true
,
true
);
return
AscCommonExcel
.
getCurrencyFormat
(
cultureInfo
,
2
,
true
,
true
);
};
};
spreadsheet_api
.
prototype
.
asc_setLocale
=
function
(
val
)
{
spreadsheet_api
.
prototype
.
asc_setLocale
=
function
(
val
)
{
if
(
!
this
.
isLoadFullApi
)
{
if
(
!
this
.
isLoadFullApi
)
{
...
...
cell/model/WorkbookElems.js
View file @
aadc52b5
This diff is collapsed.
Click to expand it.
common/NumFormat.js
View file @
aadc52b5
This diff is collapsed.
Click to expand it.
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