@himail/xlsx 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -13
- package/lib/index.js +7 -0
- package/package.json +4 -5
- package/lib/index.d.ts +0 -12
- package/lib/script/postinstall.js +0 -15
- package/lib/script/switch-cli.js +0 -14
- package/lib/script/utils.js +0 -31
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @himail/xlsx
|
|
2
2
|
|
|
3
3
|
Excel 文档预览组件,支持 Vue 2 和 Vue 3。
|
|
4
4
|
|
|
@@ -17,13 +17,13 @@ Excel 文档预览组件,支持 Vue 2 和 Vue 3。
|
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
19
|
# 使用 npm
|
|
20
|
-
npm install @
|
|
20
|
+
npm install @himail/xlsx
|
|
21
21
|
|
|
22
22
|
# 使用 yarn
|
|
23
|
-
yarn add @
|
|
23
|
+
yarn add @himail/xlsx
|
|
24
24
|
|
|
25
25
|
# 使用 pnpm
|
|
26
|
-
pnpm add @
|
|
26
|
+
pnpm add @himail/xlsx
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
## 使用
|
|
@@ -33,13 +33,13 @@ pnpm add @xm/excel
|
|
|
33
33
|
```vue
|
|
34
34
|
<template>
|
|
35
35
|
<div>
|
|
36
|
-
<
|
|
36
|
+
<HimailXlsx :src="excelFile" @load="onLoad" @error="onError" />
|
|
37
37
|
</div>
|
|
38
38
|
</template>
|
|
39
39
|
|
|
40
40
|
<script setup>
|
|
41
41
|
import { ref } from "vue";
|
|
42
|
-
import
|
|
42
|
+
import HimailXlsx from "@himail/xlsx";
|
|
43
43
|
|
|
44
44
|
const excelFile = ref("https://example.com/sample.xlsx");
|
|
45
45
|
|
|
@@ -58,16 +58,16 @@ const onError = (error) => {
|
|
|
58
58
|
```vue
|
|
59
59
|
<template>
|
|
60
60
|
<div>
|
|
61
|
-
<
|
|
61
|
+
<HimailXlsx :src="excelFile" @load="onLoad" @error="onError" />
|
|
62
62
|
</div>
|
|
63
63
|
</template>
|
|
64
64
|
|
|
65
65
|
<script>
|
|
66
|
-
import
|
|
66
|
+
import HimailXlsx from "@himail/xlsx";
|
|
67
67
|
|
|
68
68
|
export default {
|
|
69
69
|
components: {
|
|
70
|
-
|
|
70
|
+
HimailXlsx,
|
|
71
71
|
},
|
|
72
72
|
data() {
|
|
73
73
|
return {
|
|
@@ -112,19 +112,19 @@ export default {
|
|
|
112
112
|
### 基本使用
|
|
113
113
|
|
|
114
114
|
```vue
|
|
115
|
-
<
|
|
115
|
+
<HimailXlsx src="/path/to/excel.xlsx" />
|
|
116
116
|
```
|
|
117
117
|
|
|
118
118
|
### 带自定义样式
|
|
119
119
|
|
|
120
120
|
```vue
|
|
121
|
-
<
|
|
121
|
+
<HimailXlsx src="/path/to/excel.xlsx" width="800px" height="500px" />
|
|
122
122
|
```
|
|
123
123
|
|
|
124
124
|
### 监听事件
|
|
125
125
|
|
|
126
126
|
```vue
|
|
127
|
-
<
|
|
127
|
+
<HimailXlsx
|
|
128
128
|
src="/path/to/excel.xlsx"
|
|
129
129
|
@load="handleLoad"
|
|
130
130
|
@error="handleError"
|
|
@@ -141,7 +141,7 @@ export default {
|
|
|
141
141
|
|
|
142
142
|
## 许可证
|
|
143
143
|
|
|
144
|
-
|
|
144
|
+
Apache 2.0 License
|
|
145
145
|
|
|
146
146
|
## 贡献
|
|
147
147
|
|
package/lib/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@himail/xlsx",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -13,10 +13,9 @@
|
|
|
13
13
|
"copyReadme": "cp ../../../help.md README.md || true",
|
|
14
14
|
"copyType": "cp index.d.ts lib/index.d.ts",
|
|
15
15
|
"copyScripts": "mkdir -p lib/script/ && cp ../../script/postinstall.js lib/script/postinstall.js && cp ../../script/switch-cli.js lib/script/switch-cli.js && cp ../../script/utils.js lib/script/utils.js",
|
|
16
|
-
"build:2": "
|
|
17
|
-
"build:3": "
|
|
18
|
-
"build": "npm run clean && npm run build:3 && npm run copyScripts && npm run copyType"
|
|
19
|
-
"postinstall": "node lib/script/postinstall.js"
|
|
16
|
+
"build:2": "node ../../node_modules/vue-demi/bin/vue-demi-switch.js 2 vue2 && vite build && npm run copyFile2",
|
|
17
|
+
"build:3": "node ../../node_modules/vue-demi/bin/vue-demi-switch.js 3 vue3 && vite build && npm run copyFile3",
|
|
18
|
+
"build": "npm run clean && npm run build:3 && npm run copyScripts && npm run copyType"
|
|
20
19
|
},
|
|
21
20
|
"peerDependencies": {
|
|
22
21
|
"@vue/composition-api": "^1.7.1",
|
package/lib/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface Options {
|
|
2
|
-
minColLength?: number;
|
|
3
|
-
minRowLength?: number;
|
|
4
|
-
showContextmenu?: boolean;
|
|
5
|
-
}
|
|
6
|
-
declare const xmExcel: {
|
|
7
|
-
install?: (vue: any) => void;
|
|
8
|
-
src: string | ArrayBuffer | Blob;
|
|
9
|
-
requestOptions?: any;
|
|
10
|
-
options?: Options;
|
|
11
|
-
};
|
|
12
|
-
export default xmExcel;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const { switchVersion, loadModule } = require('./utils');
|
|
2
|
-
const Vue = loadModule('vue');
|
|
3
|
-
if (!Vue || typeof Vue.version !== 'string') {
|
|
4
|
-
console.warn(
|
|
5
|
-
'[vue-office] Vue is not found. Please run "npm install vue" to install.'
|
|
6
|
-
);
|
|
7
|
-
} else if (Vue.version.startsWith('2.')) {
|
|
8
|
-
switchVersion(2);
|
|
9
|
-
} else if (Vue.version.startsWith('3.')) {
|
|
10
|
-
switchVersion(3);
|
|
11
|
-
} else {
|
|
12
|
-
console.warn(
|
|
13
|
-
`[vue-office] Vue version v${Vue.version} is not supported.`
|
|
14
|
-
);
|
|
15
|
-
}
|
package/lib/script/switch-cli.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const { switchVersion } = require('./utils');
|
|
2
|
-
|
|
3
|
-
const version = process.argv[2];
|
|
4
|
-
|
|
5
|
-
if (version == '2') {
|
|
6
|
-
switchVersion(2);
|
|
7
|
-
} else if (version == '3') {
|
|
8
|
-
switchVersion(3);
|
|
9
|
-
} else {
|
|
10
|
-
console.warn(
|
|
11
|
-
`[vue-office] expecting version "2" or "3" but got "${version}"`
|
|
12
|
-
);
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
package/lib/script/utils.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const dir = path.resolve(__dirname, '../');
|
|
4
|
-
function loadModule(name) {
|
|
5
|
-
try {
|
|
6
|
-
return require(name);
|
|
7
|
-
} catch (e) {
|
|
8
|
-
return undefined;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function copy(name, version) {
|
|
13
|
-
const src = path.join(dir, `v${version}`, name);
|
|
14
|
-
const dest = path.join(dir, name);
|
|
15
|
-
if(!fs.existsSync(src)){
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
let content = fs.readFileSync(src, 'utf-8');
|
|
19
|
-
try {
|
|
20
|
-
fs.unlinkSync(dest);
|
|
21
|
-
} catch (error) {}
|
|
22
|
-
fs.writeFileSync(dest, content, 'utf-8');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function switchVersion(version) {
|
|
26
|
-
copy('index.js', version);
|
|
27
|
-
copy('index.css', version);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
module.exports.loadModule = loadModule;
|
|
31
|
-
module.exports.switchVersion = switchVersion;
|