Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
admin-fe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sean King
admin-fe
Commits
6ecf8b82
Commit
6ecf8b82
authored
6 years ago
by
Shaw
Committed by
花裤衩
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix poor naming formats and typo in UploadExcel component (#1047)
parent
a5dd905b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/UploadExcel/index.vue
+11
-9
11 additions, 9 deletions
src/components/UploadExcel/index.vue
with
11 additions
and
9 deletions
src/components/UploadExcel/index.vue
+
11
−
9
View file @
6ecf8b82
...
...
@@ -26,7 +26,7 @@ export default {
}
},
methods
:
{
generateDat
e
({
header
,
results
})
{
generateDat
a
({
header
,
results
})
{
this
.
excelData
.
header
=
header
this
.
excelData
.
results
=
results
this
.
onSuccess
&&
this
.
onSuccess
(
this
.
excelData
)
...
...
@@ -82,20 +82,20 @@ export default {
const
reader
=
new
FileReader
()
reader
.
onload
=
e
=>
{
const
data
=
e
.
target
.
result
const
fixedData
=
this
.
fix
d
ata
(
data
)
const
fixedData
=
this
.
fix
D
ata
(
data
)
const
workbook
=
XLSX
.
read
(
btoa
(
fixedData
),
{
type
:
'
base64
'
})
const
firstSheetName
=
workbook
.
SheetNames
[
0
]
const
worksheet
=
workbook
.
Sheets
[
firstSheetName
]
const
header
=
this
.
get
_h
eader
_r
ow
(
worksheet
)
const
header
=
this
.
get
H
eader
R
ow
(
worksheet
)
const
results
=
XLSX
.
utils
.
sheet_to_json
(
worksheet
)
this
.
generateDat
e
({
header
,
results
})
this
.
generateDat
a
({
header
,
results
})
this
.
loading
=
false
resolve
()
}
reader
.
readAsArrayBuffer
(
rawFile
)
})
},
fix
d
ata
(
data
)
{
fix
D
ata
(
data
)
{
let
o
=
''
let
l
=
0
const
w
=
10240
...
...
@@ -103,14 +103,16 @@ export default {
o
+=
String
.
fromCharCode
.
apply
(
null
,
new
Uint8Array
(
data
.
slice
(
l
*
w
)))
return
o
},
get
_h
eader
_r
ow
(
sheet
)
{
get
H
eader
R
ow
(
sheet
)
{
const
headers
=
[]
const
range
=
XLSX
.
utils
.
decode_range
(
sheet
[
'
!ref
'
])
let
C
const
R
=
range
.
s
.
r
/* start in the first row */
const
R
=
range
.
s
.
r
/* start in the first row */
for
(
C
=
range
.
s
.
c
;
C
<=
range
.
e
.
c
;
++
C
)
{
/* walk every column in the range */
var
cell
=
sheet
[
XLSX
.
utils
.
encode_cell
({
c
:
C
,
r
:
R
})]
/* find the cell in the first row */
var
hdr
=
'
UNKNOWN
'
+
C
//
<--
replace
with
your
desired
default
const
cell
=
sheet
[
XLSX
.
utils
.
encode_cell
({
c
:
C
,
r
:
R
})]
/* find the cell in the first row */
let
hdr
=
'
UNKNOWN
'
+
C
//
<--
replace
with
your
desired
default
if
(
cell
&&
cell
.
t
)
hdr
=
XLSX
.
utils
.
format_cell
(
cell
)
headers
.
push
(
hdr
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment