File tree Expand file tree Collapse file tree 1 file changed +1
-10
lines changed
src/components/UploadExcel Expand file tree Collapse file tree 1 file changed +1
-10
lines changed Original file line number Diff line number Diff line change @@ -82,8 +82,7 @@ export default {
8282 const reader = new FileReader ()
8383 reader .onload = e => {
8484 const data = e .target .result
85- const fixedData = this .fixData (data)
86- const workbook = XLSX .read (btoa (fixedData), { type: ' base64' })
85+ const workbook = XLSX .read (data, { type: ' array' })
8786 const firstSheetName = workbook .SheetNames [0 ]
8887 const worksheet = workbook .Sheets [firstSheetName]
8988 const header = this .getHeaderRow (worksheet)
@@ -95,14 +94,6 @@ export default {
9594 reader .readAsArrayBuffer (rawFile)
9695 })
9796 },
98- fixData (data ) {
99- let o = ' '
100- let l = 0
101- const w = 10240
102- for (; l < data .byteLength / w; ++ l) o += String .fromCharCode .apply (null , new Uint8Array (data .slice (l * w, l * w + w)))
103- o += String .fromCharCode .apply (null , new Uint8Array (data .slice (l * w)))
104- return o
105- },
10697 getHeaderRow (sheet ) {
10798 const headers = []
10899 const range = XLSX .utils .decode_range (sheet[' !ref' ])
You can’t perform that action at this time.
0 commit comments