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
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
Pleroma
admin-fe
Commits
3153a1b1
Unverified
Commit
3153a1b1
authored
6 years ago
by
花裤衩
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
perf[UploadExcel]: optimized code (#1552)
parent
23055c9b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/UploadExcel/index.vue
+1
-10
1 addition, 10 deletions
src/components/UploadExcel/index.vue
with
1 addition
and
10 deletions
src/components/UploadExcel/index.vue
+
1
−
10
View file @
3153a1b1
...
...
@@ -82,8 +82,7 @@ export default {
const
reader
=
new
FileReader
()
reader
.
onload
=
e
=>
{
const
data
=
e
.
target
.
result
const
fixedData
=
this
.
fixData
(
data
)
const
workbook
=
XLSX
.
read
(
btoa
(
fixedData
),
{
type
:
'
base64
'
})
const
workbook
=
XLSX
.
read
(
data
,
{
type
:
'
array
'
})
const
firstSheetName
=
workbook
.
SheetNames
[
0
]
const
worksheet
=
workbook
.
Sheets
[
firstSheetName
]
const
header
=
this
.
getHeaderRow
(
worksheet
)
...
...
@@ -95,14 +94,6 @@ export default {
reader
.
readAsArrayBuffer
(
rawFile
)
})
},
fixData
(
data
)
{
let
o
=
''
let
l
=
0
const
w
=
10240
for
(;
l
<
data
.
byteLength
/
w
;
++
l
)
o
+=
String
.
fromCharCode
.
apply
(
null
,
new
Uint8Array
(
data
.
slice
(
l
*
w
,
l
*
w
+
w
)))
o
+=
String
.
fromCharCode
.
apply
(
null
,
new
Uint8Array
(
data
.
slice
(
l
*
w
)))
return
o
},
getHeaderRow
(
sheet
)
{
const
headers
=
[]
const
range
=
XLSX
.
utils
.
decode_range
(
sheet
[
'
!ref
'
])
...
...
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