Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

feat(sheets-plugin): add import xlsx plugin template

Dushusir5403c2ceb0c8
diff --git a/cli/src/templates/base/index.html b/cli/src/templates/base/index.html
index e8b1031294..884f135aab 100644
--- a/cli/src/templates/base/index.html
+++ b/cli/src/templates/base/index.html
@@ -17,7 +17,7 @@
<body>
<div id="app"></div>
- <div id="universheet-demo" style="height: 100%;"></div>
+ <div id="universheet" style="height: 100%;"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
diff --git a/cli/src/templates/base/package.json b/cli/src/templates/base/package.json
index babed969bd..7981cc63d5 100644
--- a/cli/src/templates/base/package.json
+++ b/cli/src/templates/base/package.json
@@ -15,13 +15,13 @@
"exports": {
".": {
"import": {
- "node": "./lib/univer-<%= projectName %>.cjs.js",
- "default": "./lib/univer-<%= projectName %>.es.js"
+ "node": "./lib/univer-<%= projectName %>.cjs.js",
+ "default": "./lib/univer-<%= projectName %>.es.js"
},
"require": "./lib/univer-<%= projectName %>.cjs.js",
"types": "./lib/univer-<%= projectName %>.d.ts"
- },
- "./*": "./src/*"
+ },
+ "./*": "./src/*"
},
"directories": {
"lib": "lib"
@@ -58,11 +58,11 @@
"vite": "^2.4.4"
},
"dependencies": {
- "@univer/<%= projectName %>": "workspace:^0.0.1",
+ "@univer/common-plugin-data": "workspace:^0.0.1",
+ "@univer/base-component": "workspace:^0.0.1",
"@univer/base-render": "workspace:^0.0.1",
"@univer/core": "workspace:^0.0.1",
"@univer/base-sheets": "workspace:^0.0.1",
- "@univer/sheets-plugin-filter": "workspace:^0.0.1",
"@univer/style-universheet": "workspace:^0.0.1",
"preact": "^10.5.14"
}
diff --git a/cli/src/templates/base/src/Basic/Const/index.ts b/cli/src/templates/base/src/Basic/Const/index.ts
index e69de29bb2..0dc96d927a 100644
--- a/cli/src/templates/base/src/Basic/Const/index.ts
+++ b/cli/src/templates/base/src/Basic/Const/index.ts
@@ -0,0 +1 @@
+export * from './PLUGIN_NAME';
diff --git a/cli/src/templates/base/src/Controller/SortController.ts b/cli/src/templates/base/src/Controller/SortController.ts
new file mode 100644
index 0000000000..579edc8d44
--- /dev/null
+++ b/cli/src/templates/base/src/Controller/SortController.ts
@@ -0,0 +1,13 @@
+import { BaseComponentRender } from '@univer/base-component';
+import { <%= projectUpperValue %>Plugin } from '../<%= projectUpperValue %>Plugin';
+
+export class <%= projectUpperValue %>Controller {
+
+ protected _plugin: <%= projectUpperValue %>Plugin;
+
+ protected _render: BaseComponentRender;
+
+ constructor(plugin: <%= projectUpperValue %>Plugin) {
+ this._plugin = plugin;
+ }
+}
diff --git a/cli/src/templates/base/src/Locale/en.ts b/cli/src/templates/base/src/Locale/en.ts
index bbd272d166..e60e73303a 100644
--- a/cli/src/templates/base/src/Locale/en.ts
+++ b/cli/src/templates/base/src/Locale/en.ts
@@ -1,9 +1,8 @@
export default {
- <%= projectValue %>Label: '<%= projectUpperValue %>',
- <%= projectValue %>RightLabel: 'more <%= projectUpperValue %>',
<%= projectValue %>: {
- one: 'one',
- two: 'two',
- three: 'three',
+ tooltip: '<%= projectUpperValue %>',
+ one:'one',
+ two:'two',
+ three:'three',
},
};
diff --git a/cli/src/templates/base/src/Locale/zh.ts b/cli/src/templates/base/src/Locale/zh.ts
index 8f53e28356..3288d76f8e 100644
--- a/cli/src/templates/base/src/Locale/zh.ts
+++ b/cli/src/templates/base/src/Locale/zh.ts
@@ -1,9 +1,8 @@
export default {
- <%= projectValue %>Label: '插件',
- <%= projectValue %>RightLabel: '更多 <%= projectUpperValue %>',
<%= projectValue %>: {
- one: '一',
- two: '二',
- three: '三',
+ tooltip: '<%= projectUpperValue %>',
+ one:'一',
+ two:'二',
+ three:'三',
},
};
diff --git a/cli/src/templates/base/src/SortPlugin.tsx b/cli/src/templates/base/src/SortPlugin.tsx
index c21b7444a9..b84730f067 100644
--- a/cli/src/templates/base/src/SortPlugin.tsx
+++ b/cli/src/templates/base/src/SortPlugin.tsx
@@ -1,16 +1,13 @@
-import { Context, Plugin, PLUGIN_NAMES, UniverSheet } from '@univer/core';
-import { <%= projectUpperValue %>Button } from './View/UI/<%= projectUpperValue %>Button';
+import { Plugin, UniverSheet } from '@univer/core';
import { zh, en } from './Locale';
-
-import { IToolBarItemProps, ISlotElement } from '@univer/base-component';
-import { IOCContainer } from '@univer/core';
-import { SheetPlugin } from '@univer/base-sheets';
import { <%= projectConstantValue %>_PLUGIN_NAME} from './Basic/Const/PLUGIN_NAME'
+import { <%= projectUpperValue %>Controller } from './Controller/<%= projectUpperValue %>Controller';
export interface I<%= projectUpperValue %>PluginConfig {}
export class <%= projectUpperValue %>Plugin extends Plugin {
-
+ private _<%= projectValue %>Controller: <%= projectUpperValue %>Controller;
+
constructor(config ?: I<%= projectUpperValue %>PluginConfig) {
super(<%= projectConstantValue %>_PLUGIN_NAME);
}
@@ -35,20 +32,12 @@ export class <%= projectUpperValue %>Plugin extends Plugin {
zh: zh,
});
- const item: IToolBarItemProps = {
- locale: '<%= projectValue %>',
- type: ISlotElement.JSX,
- show: true,
- label: <<%= projectUpperValue %>Button />
- }
- context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.addButton(item)
-}
-
-onMapping(IOC: IOCContainer): void {}
+ this._<%= projectValue %>Controller = new <%= projectUpperValue %>Controller(this);
+ }
-onMounted(ctx: Context): void {
- this.initialize()
-}
+ onMounted(): void {
+ this.initialize()
+ }
-onDestroy(): void {}
+ onDestroy(): void {}
}
diff --git a/cli/src/templates/base/src/View/UI/SortButton.tsx b/cli/src/templates/base/src/View/UI/SortButton.tsx
deleted file mode 100644
index 725533bf60..0000000000
--- a/cli/src/templates/base/src/View/UI/SortButton.tsx
+++ /dev/null
@@ -1,104 +0,0 @@
-import { Nullable, Observer } from '@univer/core';
-import { ISelectButton, IToolBarItemProps, Component, BaseSelectProps } from '@univer/base-component';
-
-interface IProps {}
-// Types for state
-interface IState {
- <%= projectValue %>: IToolBarItemProps;
-}
-
-export class <%= projectUpperValue %>Button extends Component<IProps, IState> {
-
- private _localeObserver: Nullable<Observer<void>>;
- initialize(props: IProps) {
-
- const OrderASCIcon = this.getComponentRender().renderFunction('OrderASCIcon');
- const OrderDESCIcon = this.getComponentRender().renderFunction('OrderDESCIcon');
- const OrderIcon = this.getComponentRender().renderFunction('OrderIcon');
- const NextIcon = this.getComponentRender().renderFunction('NextIcon');
-
- const <%= projectValue %>: IToolBarItemProps = {
- locale: '<%= projectValue %>',
- type: 'select',
- label: <OrderASCIcon />,
- icon: <NextIcon />,
- show: true,
- border: false,
- selectType: ISelectButton.DOUBLE,
- needChange: false,
- children: [
- {
- locale: '<%= projectValue %>.one',
- icon: <OrderASCIcon />,
- },
- {
- locale: '<%= projectValue %>.two',
- icon: <OrderDESCIcon />,
- },
- {
- locale: '<%= projectValue %>.three',
- icon: <OrderIcon />,
- },
- ],
- };
-
- this.state = {
- <%= projectValue %>: <%= projectValue %>,
- };
- }
-
- /**
- * init
- */
- componentWillMount() {
- this.setLocale();
-
- // subscribe Locale change event
-
- this._localeObserver = this._context.getObserverManager().getObserver('onAfterChangeUILocaleObservable','core')?.add(() => {
- this.setLocale();
- });
- }
- /**
- * destory
- */
- componentWillUnmount() {
- // this._context.getObserverManager().getObserver('onAfterChangeUILocaleObservable','core')?.remove(this._localeObserver);
- }
- /**
- * set text by config setting and Locale message
- */
- setLocale() {
- const locale = this._context.getLocale();
- this.setState((prevState: IState) => {
- let item = prevState.<%= projectValue %>;
- // set current Locale string for tooltip
- item.tooltip = locale.get(`${item.locale}Label`);
- item.tooltipRight = locale.get(`${item.locale}RightLabel`);
-
- // set current Locale string for select
- item.children?.forEach((ele: IToolBarItemProps) => {
- if (ele.locale) {
- ele.label = locale.get(`${ele.locale}`);
- }
- });
- item.label = typeof item.label == 'object' ? item.label : item.children![0].label;
-
- return {
- <%= projectValue %>: item,
- };
- });
- }
-
- /**
- * Render the component's HTML
- *
- * @returns {void}
- */
- render(props: IProps, state: IState) {
- const { <%= projectValue %> } = state;
- const Select = this.getComponentRender().renderFunction('Select');
- // Set Provider for entire Container
- return <Select tooltip={<%= projectValue %>.tooltip} tooltipRight={<%= projectValue %>.tooltipRight} border={<%= projectValue %>.border} needChange={<%= projectValue %>.needChange} key={<%= projectValue %>.locale} children={<%= projectValue %>.children as BaseSelectProps[]} label={<%= projectValue %>.label} icon={<%= projectValue %>.icon} />;
- }
-}
diff --git a/cli/src/templates/base/src/View/UI/index.ts b/cli/src/templates/base/src/View/UI/index.ts
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/cli/src/templates/base/src/main.tsx b/cli/src/templates/base/src/main.tsx
index bacb968b69..2dbe46aba9 100644
--- a/cli/src/templates/base/src/main.tsx
+++ b/cli/src/templates/base/src/main.tsx
@@ -1,22 +1,21 @@
-import { defaultWorkbookData, UniverSheet } from '@univer/core';
+import { UniverSheet } from '@univer/core';
import { RenderEngine } from '@univer/base-render';
import { SheetPlugin } from '@univer/base-sheets';
import { UniverComponentSheet } from '@univer/style-universheet';
+import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';
-import { FilterPlugin } from '@univer/sheets-plugin-filter';
import { <%= projectUpperValue %>Plugin } from './<%= projectUpperValue %>Plugin';
const uiDefaultConfigUp = {
- container: 'universheet-demo',
+ container: 'universheet',
layout: 'auto',
};
-const univerSheetUp = UniverSheet.newInstance(defaultWorkbookData);
+const univerSheetUp = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);
univerSheetUp.installPlugin(new RenderEngine());
univerSheetUp.installPlugin(new UniverComponentSheet());
univerSheetUp.installPlugin(new SheetPlugin(uiDefaultConfigUp));
-univerSheetUp.installPlugin(new FilterPlugin());
univerSheetUp.installPlugin(new <%= projectUpperValue %>Plugin());
diff --git a/cli/src/templates/common-plugin/src/Basic/Const/index.ts b/cli/src/templates/common-plugin/src/Basic/Const/index.ts
index e69de29bb2..0dc96d927a 100644
--- a/cli/src/templates/common-plugin/src/Basic/Const/index.ts
+++ b/cli/src/templates/common-plugin/src/Basic/Const/index.ts
@@ -0,0 +1 @@
+export * from './PLUGIN_NAME';
diff --git a/cli/src/templates/common-plugin/src/Controller/SortController.ts b/cli/src/templates/common-plugin/src/Controller/SortController.ts
new file mode 100644
index 0000000000..579edc8d44
--- /dev/null
+++ b/cli/src/templates/common-plugin/src/Controller/SortController.ts
@@ -0,0 +1,13 @@
+import { BaseComponentRender } from '@univer/base-component';
+import { <%= projectUpperValue %>Plugin } from '../<%= projectUpperValue %>Plugin';
+
+export class <%= projectUpperValue %>Controller {
+
+ protected _plugin: <%= projectUpperValue %>Plugin;
+
+ protected _render: BaseComponentRender;
+
+ constructor(plugin: <%= projectUpperValue %>Plugin) {
+ this._plugin = plugin;
+ }
+}
diff --git a/cli/src/templates/common-plugin/src/Locale/en.ts b/cli/src/templates/common-plugin/src/Locale/en.ts
index 7c550a79a9..e60e73303a 100644
--- a/cli/src/templates/common-plugin/src/Locale/en.ts
+++ b/cli/src/templates/common-plugin/src/Locale/en.ts
@@ -1,7 +1,6 @@
export default {
- <%= projectValue %>Label: '<%= projectUpperValue %>',
- <%= projectValue %>RightLabel: 'more <%= projectUpperValue %>',
<%= projectValue %>: {
+ tooltip: '<%= projectUpperValue %>',
one:'one',
two:'two',
three:'three',
diff --git a/cli/src/templates/common-plugin/src/Locale/zh.ts b/cli/src/templates/common-plugin/src/Locale/zh.ts
index eaecc5a5b7..3288d76f8e 100644
--- a/cli/src/templates/common-plugin/src/Locale/zh.ts
+++ b/cli/src/templates/common-plugin/src/Locale/zh.ts
@@ -1,7 +1,6 @@
export default {
- <%= projectValue %>Label: '插件',
- <%= projectValue %>RightLabel: '更多 <%= projectUpperValue %>',
<%= projectValue %>: {
+ tooltip: '<%= projectUpperValue %>',
one:'一',
two:'二',
three:'三',
diff --git a/cli/src/templates/common-plugin/src/SortPlugin.tsx b/cli/src/templates/common-plugin/src/SortPlugin.tsx
index a727e0dd95..4e88f462c1 100644
--- a/cli/src/templates/common-plugin/src/SortPlugin.tsx
+++ b/cli/src/templates/common-plugin/src/SortPlugin.tsx
@@ -1,17 +1,14 @@
-import { Context, Plugin, PLUGIN_NAMES, UniverSheet, UniverDoc, UniverSlide } from '@univer/core';
-import { <%= projectUpperValue %>Button } from './View/UI/<%= projectUpperValue %>Button';
+import { Plugin, UniverSheet, UniverDoc, UniverSlide } from '@univer/core';
import { zh, en } from './Locale';
-
-import { IToolBarItemProps, ISlotElement } from '@univer/base-component';
-import { IOCContainer } from '@univer/core';
-import { SheetPlugin } from '@univer/base-sheets';
import { <%= projectConstantValue %>_PLUGIN_NAME} from './Basic/Const/PLUGIN_NAME'
+import { <%= projectUpperValue %>Controller } from './Controller/<%= projectUpperValue %>Controller';
export interface I<%= projectUpperValue %>PluginConfig {}
export class <%= projectUpperValue %>Plugin extends Plugin {
+ private _<%= projectValue %>Controller: <%= projectUpperValue %>Controller;
- constructor(config ?: IPluginConfig) {
+ constructor(config ?: I<%= projectUpperValue %>PluginConfig) {
super(<%= projectConstantValue %>_PLUGIN_NAME);
}
@@ -34,22 +31,14 @@ export class <%= projectUpperValue %>Plugin extends Plugin {
en: en,
zh: zh,
});
-
-
- // const item: IToolBarItemProps = {
- // locale: '<%= projectValue %>',
- // type: ISlotElement.JSX,
- // show: true,
- // label: <<%= projectUpperValue %>Button />
- // }
- // context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.addToolButton(item)
-}
-onMapping(IOC: IOCContainer): void {}
+ this._<%= projectValue %>Controller = new <%= projectUpperValue %>Controller(this);
+
+ }
-onMounted(ctx: Context): void {
- this.initialize()
-}
+ onMounted(): void {
+ this.initialize()
+ }
-onDestroy(): void {}
+ onDestroy(): void {}
}
diff --git a/cli/src/templates/common-plugin/src/View/UI/SortButton.tsx b/cli/src/templates/common-plugin/src/View/UI/SortButton.tsx
deleted file mode 100644
index 725533bf60..0000000000
--- a/cli/src/templates/common-plugin/src/View/UI/SortButton.tsx
+++ /dev/null
@@ -1,104 +0,0 @@
-import { Nullable, Observer } from '@univer/core';
-import { ISelectButton, IToolBarItemProps, Component, BaseSelectProps } from '@univer/base-component';
-
-interface IProps {}
-// Types for state
-interface IState {
- <%= projectValue %>: IToolBarItemProps;
-}
-
-export class <%= projectUpperValue %>Button extends Component<IProps, IState> {
-
- private _localeObserver: Nullable<Observer<void>>;
- initialize(props: IProps) {
-
- const OrderASCIcon = this.getComponentRender().renderFunction('OrderASCIcon');
- const OrderDESCIcon = this.getComponentRender().renderFunction('OrderDESCIcon');
- const OrderIcon = this.getComponentRender().renderFunction('OrderIcon');
- const NextIcon = this.getComponentRender().renderFunction('NextIcon');
-
- const <%= projectValue %>: IToolBarItemProps = {
- locale: '<%= projectValue %>',
- type: 'select',
- label: <OrderASCIcon />,
- icon: <NextIcon />,
- show: true,
- border: false,
- selectType: ISelectButton.DOUBLE,
- needChange: false,
- children: [
- {
- locale: '<%= projectValue %>.one',
- icon: <OrderASCIcon />,
- },
- {
- locale: '<%= projectValue %>.two',
- icon: <OrderDESCIcon />,
- },
- {
- locale: '<%= projectValue %>.three',
- icon: <OrderIcon />,
- },
- ],
- };
-
- this.state = {
- <%= projectValue %>: <%= projectValue %>,
- };
- }
-
- /**
- * init
- */
- componentWillMount() {
- this.setLocale();
-
- // subscribe Locale change event
-
- this._localeObserver = this._context.getObserverManager().getObserver('onAfterChangeUILocaleObservable','core')?.add(() => {
- this.setLocale();
- });
- }
- /**
- * destory
- */
- componentWillUnmount() {
- // this._context.getObserverManager().getObserver('onAfterChangeUILocaleObservable','core')?.remove(this._localeObserver);
- }
- /**
- * set text by config setting and Locale message
- */
- setLocale() {
- const locale = this._context.getLocale();
- this.setState((prevState: IState) => {
- let item = prevState.<%= projectValue %>;
- // set current Locale string for tooltip
- item.tooltip = locale.get(`${item.locale}Label`);
- item.tooltipRight = locale.get(`${item.locale}RightLabel`);
-
- // set current Locale string for select
- item.children?.forEach((ele: IToolBarItemProps) => {
- if (ele.locale) {
- ele.label = locale.get(`${ele.locale}`);
- }
- });
- item.label = typeof item.label == 'object' ? item.label : item.children![0].label;
-
- return {
- <%= projectValue %>: item,
- };
- });
- }
-
- /**
- * Render the component's HTML
- *
- * @returns {void}
- */
- render(props: IProps, state: IState) {
- const { <%= projectValue %> } = state;
- const Select = this.getComponentRender().renderFunction('Select');
- // Set Provider for entire Container
- return <Select tooltip={<%= projectValue %>.tooltip} tooltipRight={<%= projectValue %>.tooltipRight} border={<%= projectValue %>.border} needChange={<%= projectValue %>.needChange} key={<%= projectValue %>.locale} children={<%= projectValue %>.children as BaseSelectProps[]} label={<%= projectValue %>.label} icon={<%= projectValue %>.icon} />;
- }
-}
diff --git a/cli/src/templates/common-plugin/src/View/UI/index.ts b/cli/src/templates/common-plugin/src/View/UI/index.ts
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/cli/src/templates/sheets-plugin/src/Basic/Const/index.ts b/cli/src/templates/sheets-plugin/src/Basic/Const/index.ts
index e69de29bb2..0dc96d927a 100644
--- a/cli/src/templates/sheets-plugin/src/Basic/Const/index.ts
+++ b/cli/src/templates/sheets-plugin/src/Basic/Const/index.ts
@@ -0,0 +1 @@
+export * from './PLUGIN_NAME';
diff --git a/cli/src/templates/sheets-plugin/src/Controller/SortController.ts b/cli/src/templates/sheets-plugin/src/Controller/SortController.ts
new file mode 100644
index 0000000000..6bfc12912e
--- /dev/null
+++ b/cli/src/templates/sheets-plugin/src/Controller/SortController.ts
@@ -0,0 +1,51 @@
+import { PLUGIN_NAMES } from '@univer/core';
+import { BaseComponentRender } from '@univer/base-component';
+import { IToolBarItemProps, SelectTypes, SheetPlugin } from '@univer/base-sheets';
+
+import { <%= projectConstantValue %>_PLUGIN_NAME } from '../Basic/Const';
+import { <%= projectUpperValue %>Plugin } from '../<%= projectUpperValue %>Plugin';
+
+export class <%= projectUpperValue %>Controller {
+ protected _sheetPlugin: SheetPlugin;
+
+ protected _toolButton: IToolBarItemProps;
+
+ protected _plugin: <%= projectUpperValue %>Plugin;
+
+ protected _render: BaseComponentRender;
+
+ constructor(plugin: <%= projectUpperValue %>Plugin) {
+ this._plugin = plugin;
+ this._sheetPlugin = this._plugin.getContext().getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)!;
+
+ this._toolButton = {
+ name: <%= projectConstantValue %>_PLUGIN_NAME,
+ type: SelectTypes.FIX,
+ locale: '<%= projectValue %>.tooltip',
+ tooltipLocale: '<%= projectValue %>.tooltip',
+ show: true,
+ hideSelectedIcon: true,
+ children: [
+ {
+ locale: '<%= projectValue %>.one',
+ onClick: () => {
+ console.log('one');
+ },
+ },
+ {
+ locale: '<%= projectValue %>.two',
+ onClick: () => {
+ console.log('two');
+ },
+ },
+ {
+ locale: '<%= projectValue %>.three',
+ onClick: () => {
+ console.log('three');
+ },
+ },
+ ],
+ };
+ this._sheetPlugin.addToolButton(this._toolButton);
+ }
+}
diff --git a/cli/src/templates/sheets-plugin/src/Locale/en.ts b/cli/src/templates/sheets-plugin/src/Locale/en.ts
index 7c550a79a9..e60e73303a 100644
--- a/cli/src/templates/sheets-plugin/src/Locale/en.ts
+++ b/cli/src/templates/sheets-plugin/src/Locale/en.ts
@@ -1,7 +1,6 @@
export default {
- <%= projectValue %>Label: '<%= projectUpperValue %>',
- <%= projectValue %>RightLabel: 'more <%= projectUpperValue %>',
<%= projectValue %>: {
+ tooltip: '<%= projectUpperValue %>',
one:'one',
two:'two',
three:'three',
diff --git a/cli/src/templates/sheets-plugin/src/Locale/zh.ts b/cli/src/templates/sheets-plugin/src/Locale/zh.ts
index eaecc5a5b7..3288d76f8e 100644
--- a/cli/src/templates/sheets-plugin/src/Locale/zh.ts
+++ b/cli/src/templates/sheets-plugin/src/Locale/zh.ts
@@ -1,7 +1,6 @@
export default {
- <%= projectValue %>Label: '插件',
- <%= projectValue %>RightLabel: '更多 <%= projectUpperValue %>',
<%= projectValue %>: {
+ tooltip: '<%= projectUpperValue %>',
one:'一',
two:'二',
three:'三',
diff --git a/cli/src/templates/sheets-plugin/src/SortPlugin.tsx b/cli/src/templates/sheets-plugin/src/SortPlugin.tsx
index 5818d95a7f..adc6066ff4 100644
--- a/cli/src/templates/sheets-plugin/src/SortPlugin.tsx
+++ b/cli/src/templates/sheets-plugin/src/SortPlugin.tsx
@@ -1,17 +1,14 @@
-import { Context, Plugin, PLUGIN_NAMES, UniverSheet } from '@univer/core';
-import { <%= projectUpperValue %>Button } from './View/UI/<%= projectUpperValue %>Button';
+import { Plugin, SheetContext, UniverSheet } from '@univer/core';
import { zh, en } from './Locale';
-
-import { IToolBarItemProps, ISlotElement } from '@univer/base-component';
-import { IOCContainer } from '@univer/core';
-import { SheetPlugin } from '@univer/base-sheets';
import { <%= projectConstantValue %>_PLUGIN_NAME} from './Basic/Const/PLUGIN_NAME'
+import { <%= projectUpperValue %>Controller } from './Controller/<%= projectUpperValue %>Controller';
export interface I<%= projectUpperValue %>PluginConfig {}
-export class <%= projectUpperValue %>Plugin extends Plugin {
+export class <%= projectUpperValue %>Plugin extends Plugin<any, SheetContext> {
+ private _<%= projectValue %>Controller: <%= projectUpperValue %>Controller;
- constructor(config ?: IPluginConfig) {
+ constructor(config ?: I<%= projectUpperValue %>PluginConfig) {
super(<%= projectConstantValue %>_PLUGIN_NAME);
}
@@ -35,20 +32,12 @@ export class <%= projectUpperValue %>Plugin extends Plugin {
zh: zh,
});
- const item: IToolBarItemProps = {
- locale: '<%= projectValue %>',
- type: ISlotElement.JSX,
- show: true,
- label: <<%= projectUpperValue %>Button />
- }
- context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.addToolButton(item)
-}
-
-onMapping(IOC: IOCContainer): void {}
+ this._<%= projectValue %>Controller = new <%= projectUpperValue %>Controller(this);
+ }
-onMounted(ctx: Context): void {
- this.initialize()
-}
+ onMounted(): void {
+ this.initialize()
+ }
-onDestroy(): void {}
+ onDestroy(): void {}
}
diff --git a/cli/src/templates/sheets-plugin/src/View/UI/SortButton.tsx b/cli/src/templates/sheets-plugin/src/View/UI/SortButton.tsx
deleted file mode 100644
index 725533bf60..0000000000
--- a/cli/src/templates/sheets-plugin/src/View/UI/SortButton.tsx
+++ /dev/null
@@ -1,104 +0,0 @@
-import { Nullable, Observer } from '@univer/core';
-import { ISelectButton, IToolBarItemProps, Component, BaseSelectProps } from '@univer/base-component';
-
-interface IProps {}
-// Types for state
-interface IState {
- <%= projectValue %>: IToolBarItemProps;
-}
-
-export class <%= projectUpperValue %>Button extends Component<IProps, IState> {
-
- private _localeObserver: Nullable<Observer<void>>;
- initialize(props: IProps) {
-
- const OrderASCIcon = this.getComponentRender().renderFunction('OrderASCIcon');
- const OrderDESCIcon = this.getComponentRender().renderFunction('OrderDESCIcon');
- const OrderIcon = this.getComponentRender().renderFunction('OrderIcon');
- const NextIcon = this.getComponentRender().renderFunction('NextIcon');
-
- const <%= projectValue %>: IToolBarItemProps = {
- locale: '<%= projectValue %>',
- type: 'select',
- label: <OrderASCIcon />,
- icon: <NextIcon />,
- show: true,
- border: false,
- selectType: ISelectButton.DOUBLE,
- needChange: false,
- children: [
- {
- locale: '<%= projectValue %>.one',
- icon: <OrderASCIcon />,
- },
- {
- locale: '<%= projectValue %>.two',
- icon: <OrderDESCIcon />,
- },
- {
- locale: '<%= projectValue %>.three',
- icon: <OrderIcon />,
- },
- ],
- };
-
- this.state = {
- <%= projectValue %>: <%= projectValue %>,
- };
- }
-
- /**
- * init
- */
- componentWillMount() {
- this.setLocale();
-
- // subscribe Locale change event
-
- this._localeObserver = this._context.getObserverManager().getObserver('onAfterChangeUILocaleObservable','core')?.add(() => {
- this.setLocale();
- });
- }
- /**
- * destory
- */
- componentWillUnmount() {
- // this._context.getObserverManager().getObserver('onAfterChangeUILocaleObservable','core')?.remove(this._localeObserver);
- }
- /**
- * set text by config setting and Locale message
- */
- setLocale() {
- const locale = this._context.getLocale();
- this.setState((prevState: IState) => {
- let item = prevState.<%= projectValue %>;
- // set current Locale string for tooltip
- item.tooltip = locale.get(`${item.locale}Label`);
- item.tooltipRight = locale.get(`${item.locale}RightLabel`);
-
- // set current Locale string for select
- item.children?.forEach((ele: IToolBarItemProps) => {
- if (ele.locale) {
- ele.label = locale.get(`${ele.locale}`);
- }
- });
- item.label = typeof item.label == 'object' ? item.label : item.children![0].label;
-
- return {
- <%= projectValue %>: item,
- };
- });
- }
-
- /**
- * Render the component's HTML
- *
- * @returns {void}
- */
- render(props: IProps, state: IState) {
- const { <%= projectValue %> } = state;
- const Select = this.getComponentRender().renderFunction('Select');
- // Set Provider for entire Container
- return <Select tooltip={<%= projectValue %>.tooltip} tooltipRight={<%= projectValue %>.tooltipRight} border={<%= projectValue %>.border} needChange={<%= projectValue %>.needChange} key={<%= projectValue %>.locale} children={<%= projectValue %>.children as BaseSelectProps[]} label={<%= projectValue %>.label} icon={<%= projectValue %>.icon} />;
- }
-}
diff --git a/cli/src/templates/sheets-plugin/src/View/UI/index.ts b/cli/src/templates/sheets-plugin/src/View/UI/index.ts
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/packages/base-sheets/src/Controller/ToolBarController.ts b/packages/base-sheets/src/Controller/ToolBarController.ts
index 7ee74e458e..f1d4c3cbb4 100644
--- a/packages/base-sheets/src/Controller/ToolBarController.ts
+++ b/packages/base-sheets/src/Controller/ToolBarController.ts
@@ -214,6 +214,7 @@ export class ToolBarController {
show: config.fontSize,
name: 'fontSize',
onClick: (fontSize: number) => {
+ debugger;
this._plugin.getObserver('onAfterChangeFontSizeObservable')?.notifyObservers(fontSize);
},
onKeyUp: (fontSize: number) => {
diff --git a/packages/base-sheets/src/Model/ToolBarModel.ts b/packages/base-sheets/src/Model/ToolBarModel.ts
index 173c53cf8f..7b3932ad84 100644
--- a/packages/base-sheets/src/Model/ToolBarModel.ts
+++ b/packages/base-sheets/src/Model/ToolBarModel.ts
@@ -49,7 +49,7 @@ export interface IToolBarItemProps extends BaseToolBarSelectProps, BaseTextButto
show?: boolean; //是否显示按钮
toolbarType?: ToolbarType;
locale?: string; //label国际化
- tooltipLocale?: string; //tooltip国际化
+ tooltipLocale?: string; //tooltip国际化 TODO: need right label
tooltip?: string; //tooltip文字
border?: boolean;
}
diff --git a/packages/base-sheets/src/View/UI/Common/Select/Select.tsx b/packages/base-sheets/src/View/UI/Common/Select/Select.tsx
index 82397c0db8..ab8c2eeca6 100644
--- a/packages/base-sheets/src/View/UI/Common/Select/Select.tsx
+++ b/packages/base-sheets/src/View/UI/Common/Select/Select.tsx
@@ -3,7 +3,7 @@ import { ColorPicker, Dropdown } from '@univer/style-universheet';
import { BaseItemProps, Item } from '../Item/Item';
import styles from './index.module.less';
-enum SelectTypes {
+export enum SelectTypes {
SINGLE, // 普通下拉
INPUT,
COLOR,
diff --git a/packages/sheets-plugin-import-xlsx/.eslintrc.js b/packages/sheets-plugin-import-xlsx/.eslintrc.js
new file mode 100644
index 0000000000..7f4cf3e7ba
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/.eslintrc.js
@@ -0,0 +1,51 @@
+module.exports = {
+ env: {
+ browser: true,
+ es2021: true,
+ node: true,
+ },
+ parser: '@typescript-eslint/parser',
+ extends: [
+ 'airbnb-typescript',
+ 'prettier',
+ 'eslint:recommended',
+ 'plugin:import/recommended',
+ 'plugin:import/typescript',
+ ],
+ parserOptions: {
+ ecmaVersion: 12,
+ sourceType: 'module',
+ project: './tsconfig.json',
+ },
+ plugins: ['@typescript-eslint', 'prettier', 'import'],
+ rules: {
+ 'prettier/prettier': [
+ 'error',
+ {
+ endOfLine: 'auto',
+ },
+ ],
+ 'import/prefer-default-export': 'off',
+ 'import/no-extraneous-dependencies': [
+ 'error',
+ { devDependencies: true },
+ ],
+ // turn on errors for missing imports
+ 'import/no-unresolved': 'error',
+ },
+ settings: {
+ 'import/parsers': {
+ '@typescript-eslint/parser': ['.ts', '.tsx'],
+ },
+ 'import/resolver': {
+ typescript: {
+ alwaysTryTypes: true, // always try to resolve config under `<root>@config` directory even it doesn't contain any source code, like `@config/unist`
+
+ // Choose from one of the "project" configs below or omit to use <root>/tsconfig.json by default
+
+ // use <root>/path/to/folder/tsconfig.json
+ project: './tsconfig.json',
+ },
+ },
+ },
+};
diff --git a/packages/sheets-plugin-import-xlsx/.gitignore b/packages/sheets-plugin-import-xlsx/.gitignore
new file mode 100644
index 0000000000..12e1bd6bec
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/.gitignore
@@ -0,0 +1,101 @@
+#ide
+*.DS_Store
+.idea
+.vscode
+
+#npm
+package-lock.json
+
+dist
+lib
+docs/.vuepress/dist
+
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+lerna-debug.log*
+
+# Runtime config
+pids
+*.pid
+*.seed
+*.pid.lock
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+
+# nyc test coverage
+.nyc_output
+
+# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# Bower dependency directory (https://bower.io/)
+bower_components
+
+# node-waf configuration
+.lock-wscript
+
+# Compiled binary addons (https://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directories
+node_modules
+jspm_packages/
+
+# TypeScript v1 declaration files
+typings/
+
+# Optional npm cache directory
+.npm
+
+# Optional eslint cache
+.eslintcache
+
+# Optional REPL History
+.node_repl_history
+
+# Output of 'npm pack'
+*.tgz
+
+# Yarn Integrity file
+.yarn-integrity
+
+# dotenv environment variables file
+.env
+
+# next.js build output
+.next
+
+#lerna-changelog
+.changelog
+
+
+#editor workspace file
+.idea/
+
+
+.DS_Store
+
+.history
+# examples
+
+
+# Production
+/build
+
+# Generated files
+.docusaurus
+.cache-loader
+
+# Misc
+.env.local
+.env.development.local
+.env.test.local
+.env.production.local
diff --git a/packages/sheets-plugin-import-xlsx/.prettierrc.cjs b/packages/sheets-plugin-import-xlsx/.prettierrc.cjs
new file mode 100644
index 0000000000..6604107223
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/.prettierrc.cjs
@@ -0,0 +1,7 @@
+module.exports = {
+ singleQuote: true,
+ trailingComma: 'es5',
+ tabWidth: 4,
+ semi: true,
+ printWidth: 180,
+};
diff --git a/packages/sheets-plugin-import-xlsx/README-zh.md b/packages/sheets-plugin-import-xlsx/README-zh.md
new file mode 100644
index 0000000000..775c4ff0d7
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/README-zh.md
@@ -0,0 +1,55 @@
+# style-universheet
+
+简体中文 | [English](./README.md)
+
+## 介绍
+
+UniverSheet ImportXlsx插件
+
+### 安装
+
+```bash
+npm i @univer/sheets-plugin-import-xlsx
+```
+
+### 使用
+
+```js
+impport {ImportXlsx} from '@univer/sheets-plugin-import-xlsx'
+
+const univerSheet = new UniverSheet();
+univerSheet.installPlugin(new ImportXlsx());
+```
+
+## 本地开发
+
+### 环境
+
+- [Node.js](https://nodejs.org/en/) Version >= 10
+- [npm](https://www.npmjs.com/) Version >= 6
+
+### 安装
+
+```
+pnpm install
+```
+
+### 开发
+
+```
+# 当前目录 ./packages/sheets-plugin-import-xlsx/
+npm run dev
+
+# 或者项目根目录 ./
+pnpm run --filter @univer/sheets-plugin-import-xlsx dev
+```
+
+### 打包
+
+```
+# 当前目录 ./packages/sheets-plugin-import-xlsx/
+npm run build
+
+# 或者根目录 ./
+pnpm run --filter @univer/sheets-plugin-import-xlsx build
+```
diff --git a/packages/sheets-plugin-import-xlsx/README.md b/packages/sheets-plugin-import-xlsx/README.md
new file mode 100644
index 0000000000..0648027097
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/README.md
@@ -0,0 +1,55 @@
+# style-universheet
+
+English| [简体中文](./README-zh.md)
+
+## Introduction
+
+UniverSheet Plugin ImportXlsx
+
+### Installation
+
+```bash
+npm i @univer/sheets-plugin-import-xlsx
+```
+
+### Usage
+
+```js
+impport {ImportXlsx} from '@univer/sheets-plugin-import-xlsx'
+
+const univerSheet = new UniverSheet();
+univerSheet.installPlugin(new ImportXlsx());
+```
+
+## Local development
+
+### Requirements
+
+- [Node.js](https://nodejs.org/en/) Version >= 10
+- [npm](https://www.npmjs.com/) Version >= 6
+
+### Installation
+
+```
+pnpm install
+```
+
+### Development
+
+```
+# Current directory ./packages/sheets-plugin-import-xlsx/
+npm run dev
+
+# Or project root directory ./
+pnpm run --filter @univer/sheets-plugin-import-xlsx dev
+```
+
+### Package
+
+```
+# Current directory ./packages/sheets-plugin-import-xlsx/
+npm run build
+
+# Or root directory ./
+pnpm run --filter @univer/sheets-plugin-import-xlsx build
+```
diff --git a/packages/sheets-plugin-import-xlsx/index.html b/packages/sheets-plugin-import-xlsx/index.html
new file mode 100644
index 0000000000..45b8be6bf6
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/index.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8" />
+ <link rel="icon" type="image/svg+xml" href="favicon.svg" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <title>UniverSheet</title>
+ <style>
+ html,
+ body {
+ height: 100%;
+ margin: 0;
+ }
+ </style>
+</head>
+
+<body>
+ <div id="app" style="position:absolute;z-index: 99999;"></div>
+ <div id="universheet-demo" style="height: 100%;"></div>
+ <script type="module" src="/src/main.tsx"></script>
+</body>
+
+</html>
\ No newline at end of file
diff --git a/packages/sheets-plugin-import-xlsx/jest.config.js b/packages/sheets-plugin-import-xlsx/jest.config.js
new file mode 100644
index 0000000000..73ef4bae42
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/jest.config.js
@@ -0,0 +1,18 @@
+/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
+module.exports = {
+ preset: 'ts-jest',
+ testEnvironment: 'jsdom',
+ moduleFileExtensions: ['js', 'ts', 'tsx'],
+
+ roots: ['<rootDir>/src'],
+ testMatch: ['**/__tests__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'],
+ transform: {
+ '^.+\\.(ts|tsx)$': 'ts-jest',
+ '^.+\\.tsx?$': 'babel-jest', // https://github.com/kulshekhar/ts-jest/issues/937#issuecomment-455431207
+ },
+ globals: {
+ 'ts-jest': {
+ tsConfig: 'tsconfig.test.json',
+ },
+ },
+};
diff --git a/packages/sheets-plugin-import-xlsx/package.json b/packages/sheets-plugin-import-xlsx/package.json
new file mode 100644
index 0000000000..ca7745be2e
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/package.json
@@ -0,0 +1,67 @@
+{
+ "name": "@univer/sheets-plugin-import-xlsx",
+ "version": "0.0.1",
+ "description": "UniverSheet normal sheets-plugin-import-xlsx",
+ "keywords": [],
+ "author": "DreamNum <[email protected]>",
+ "license": "MIT",
+ "main": "./lib/univer-sheets-plugin-import-xlsx.cjs.js",
+ "module": "./lib/univer-sheets-plugin-import-xlsx.es.js",
+ "browser": {
+ "./lib/univer-sheets-plugin-import-xlsx.cjs.js": "./src/index.ts",
+ "./lib/univer-sheets-plugin-import-xlsx.es.js": "./src/index.ts"
+ },
+ "types": "./src/Types/index.d.ts",
+ "exports": {
+ ".": {
+ "import": {
+ "node": "./lib/univer-sheets-plugin-import-xlsx.cjs.js",
+ "default": "./lib/univer-sheets-plugin-import-xlsx.es.js"
+ },
+ "require": "./lib/univer-sheets-plugin-import-xlsx.cjs.js",
+ "types": "./lib/univer-sheets-plugin-import-xlsx.d.ts"
+ },
+ "./*": "./src/*"
+ },
+ "directories": {
+ "lib": "lib"
+ },
+ "scripts": {
+ "test": "jest",
+ "dev": "vite",
+ "build": "tsc && vite build",
+ "watch": "vite build",
+ "link": "pnpm link ./",
+ "serve": "vite preview"
+ },
+ "devDependencies": {
+ "@preact/preset-vite": "2.0.0",
+ "@testing-library/preact": "^2.0.1",
+ "@types/jest": "^27.0.1",
+ "@types/node": "^16.4.6",
+ "@vitejs/plugin-legacy": "^1.5.1",
+ "eslint": "^8.22.0",
+ "eslint-config-airbnb-typescript": "^17.0.0",
+ "eslint-config-prettier": "^8.3.0",
+ "eslint-plugin-import": "^2.23.4",
+ "eslint-plugin-prettier": "^3.4.0",
+ "eslint-plugin-jsx-a11y": "^6.5.1",
+ "eslint-plugin-react": "^7.28.0",
+ "eslint-plugin-react-hooks": "^4.3.0",
+ "less": "^4.1.1",
+ "prettier": "^2.3.2",
+ "ts-jest": "29.0.1",
+ "ts-node": "^10.2.1",
+ "typescript": "^4.4.1-rc",
+ "vite": "^2.4.4"
+ },
+ "dependencies": {
+ "@univer/common-plugin-data": "workspace:^0.0.1",
+ "@univer/base-component": "workspace:^0.0.1",
+ "@univer/base-render": "workspace:^0.0.1",
+ "@univer/core": "workspace:^0.0.1",
+ "@univer/base-sheets": "workspace:^0.0.1",
+ "@univer/style-universheet": "workspace:^0.0.1",
+ "preact": "^10.5.14"
+ }
+}
diff --git a/packages/sheets-plugin-import-xlsx/src/Basic/Const/PLUGIN_NAME.ts b/packages/sheets-plugin-import-xlsx/src/Basic/Const/PLUGIN_NAME.ts
new file mode 100644
index 0000000000..4f23dac8c0
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/src/Basic/Const/PLUGIN_NAME.ts
@@ -0,0 +1 @@
+export const IMPORT_XLSX_PLUGIN_NAME = 'importXlsx';
diff --git a/packages/sheets-plugin-import-xlsx/src/Basic/Const/index.ts b/packages/sheets-plugin-import-xlsx/src/Basic/Const/index.ts
new file mode 100644
index 0000000000..0dc96d927a
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/src/Basic/Const/index.ts
@@ -0,0 +1 @@
+export * from './PLUGIN_NAME';
diff --git a/packages/sheets-plugin-import-xlsx/src/Basic/Enum/index.ts b/packages/sheets-plugin-import-xlsx/src/Basic/Enum/index.ts
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/packages/sheets-plugin-import-xlsx/src/Basic/Shared/index.ts b/packages/sheets-plugin-import-xlsx/src/Basic/Shared/index.ts
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/packages/sheets-plugin-import-xlsx/src/Basic/index.ts b/packages/sheets-plugin-import-xlsx/src/Basic/index.ts
new file mode 100644
index 0000000000..640d1bb8b3
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/src/Basic/index.ts
@@ -0,0 +1,4 @@
+export * from './Const';
+export * from './Enum';
+export * from '../Locale';
+export * from './Shared';
diff --git a/packages/sheets-plugin-import-xlsx/src/Controller/ImportXlsxController.ts b/packages/sheets-plugin-import-xlsx/src/Controller/ImportXlsxController.ts
new file mode 100644
index 0000000000..7fe7331406
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/src/Controller/ImportXlsxController.ts
@@ -0,0 +1,51 @@
+import { PLUGIN_NAMES } from '@univer/core';
+import { BaseComponentRender } from '@univer/base-component';
+import { IToolBarItemProps, SelectTypes, SheetPlugin } from '@univer/base-sheets';
+
+import { IMPORT_XLSX_PLUGIN_NAME } from '../Basic/Const';
+import { ImportXlsxPlugin } from '../ImportXlsxPlugin';
+
+export class ImportXlsxController {
+ protected _sheetPlugin: SheetPlugin;
+
+ protected _toolButton: IToolBarItemProps;
+
+ protected _plugin: ImportXlsxPlugin;
+
+ protected _render: BaseComponentRender;
+
+ constructor(plugin: ImportXlsxPlugin) {
+ this._plugin = plugin;
+ this._sheetPlugin = this._plugin.getContext().getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)!;
+
+ this._toolButton = {
+ name: IMPORT_XLSX_PLUGIN_NAME,
+ type: SelectTypes.FIX,
+ locale: 'importXlsx.tooltip',
+ tooltipLocale: 'importXlsx.tooltip',
+ show: true,
+ hideSelectedIcon: true,
+ children: [
+ {
+ locale: 'importXlsx.one',
+ onClick: () => {
+ console.log('one');
+ },
+ },
+ {
+ locale: 'importXlsx.two',
+ onClick: () => {
+ console.log('two');
+ },
+ },
+ {
+ locale: 'importXlsx.three',
+ onClick: () => {
+ console.log('three');
+ },
+ },
+ ],
+ };
+ this._sheetPlugin.addToolButton(this._toolButton);
+ }
+}
diff --git a/packages/sheets-plugin-import-xlsx/src/Controller/index.ts b/packages/sheets-plugin-import-xlsx/src/Controller/index.ts
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/packages/sheets-plugin-import-xlsx/src/ImportXlsxPlugin.tsx b/packages/sheets-plugin-import-xlsx/src/ImportXlsxPlugin.tsx
new file mode 100644
index 0000000000..f85a027486
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/src/ImportXlsxPlugin.tsx
@@ -0,0 +1,42 @@
+import { Plugin, SheetContext, UniverSheet } from '@univer/core';
+import { zh, en } from './Locale';
+import { IMPORT_XLSX_PLUGIN_NAME } from './Basic/Const/PLUGIN_NAME';
+import { ImportXlsxController } from './Controller/ImportXlsxController';
+
+export interface IImportXlsxPluginConfig {}
+
+export class ImportXlsxPlugin extends Plugin<any, SheetContext> {
+ private _importXlsxController: ImportXlsxController;
+
+ constructor(config?: IImportXlsxPluginConfig) {
+ super(IMPORT_XLSX_PLUGIN_NAME);
+ }
+
+ static create(config?: IImportXlsxPluginConfig) {
+ return new ImportXlsxPlugin(config);
+ }
+
+ installTo(universheetInstance: UniverSheet) {
+ universheetInstance.installPlugin(this);
+ }
+
+ initialize(): void {
+ const context = this.getContext();
+
+ /**
+ * load more Locale object
+ */
+ context.getLocale().load({
+ en: en,
+ zh: zh,
+ });
+
+ this._importXlsxController = new ImportXlsxController(this);
+ }
+
+ onMounted(): void {
+ this.initialize();
+ }
+
+ onDestroy(): void {}
+}
diff --git a/packages/sheets-plugin-import-xlsx/src/Locale/en.ts b/packages/sheets-plugin-import-xlsx/src/Locale/en.ts
new file mode 100644
index 0000000000..09e9cda2db
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/src/Locale/en.ts
@@ -0,0 +1,8 @@
+export default {
+ importXlsx: {
+ tooltip: 'ImportXlsx',
+ one:'one',
+ two:'two',
+ three:'three',
+ },
+};
diff --git a/packages/sheets-plugin-import-xlsx/src/Locale/index.ts b/packages/sheets-plugin-import-xlsx/src/Locale/index.ts
new file mode 100644
index 0000000000..3ac4bcd0fd
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/src/Locale/index.ts
@@ -0,0 +1,4 @@
+import zh from './zh';
+import en from './en';
+
+export { zh, en };
diff --git a/packages/sheets-plugin-import-xlsx/src/Locale/zh.ts b/packages/sheets-plugin-import-xlsx/src/Locale/zh.ts
new file mode 100644
index 0000000000..ec095153fb
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/src/Locale/zh.ts
@@ -0,0 +1,8 @@
+export default {
+ importXlsx: {
+ tooltip: 'ImportXlsx',
+ one:'一',
+ two:'二',
+ three:'三',
+ },
+};
diff --git a/packages/sheets-plugin-import-xlsx/src/Model/index.ts b/packages/sheets-plugin-import-xlsx/src/Model/index.ts
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/packages/sheets-plugin-import-xlsx/src/Service/index.ts b/packages/sheets-plugin-import-xlsx/src/Service/index.ts
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/packages/sheets-plugin-import-xlsx/src/Types/index.d.ts b/packages/sheets-plugin-import-xlsx/src/Types/index.d.ts
new file mode 100644
index 0000000000..510b1f464e
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/src/Types/index.d.ts
@@ -0,0 +1,10 @@
+/// <reference types="vite/client" />
+
+export * from '../index';
+declare module '@univer/sheets-plugin-import-xlsx' {}
+
+// use css module
+declare module '*.less' {
+ const resource: { [key: string]: string };
+ export = resource;
+}
diff --git a/packages/sheets-plugin-import-xlsx/src/Types/preact.d.ts b/packages/sheets-plugin-import-xlsx/src/Types/preact.d.ts
new file mode 100644
index 0000000000..0d092b3751
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/src/Types/preact.d.ts
@@ -0,0 +1,4 @@
+/// <reference types="enzyme-adapter-preact-pure" />
+import JSX = preact.JSX;
+
+declare module 'enzyme';
diff --git a/packages/sheets-plugin-import-xlsx/src/View/Render/index.ts b/packages/sheets-plugin-import-xlsx/src/View/Render/index.ts
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/packages/sheets-plugin-import-xlsx/src/View/UI/index.ts b/packages/sheets-plugin-import-xlsx/src/View/UI/index.ts
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/packages/sheets-plugin-import-xlsx/src/index.ts b/packages/sheets-plugin-import-xlsx/src/index.ts
new file mode 100644
index 0000000000..6730e40598
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/src/index.ts
@@ -0,0 +1,3 @@
+import { ImportXlsxPlugin } from './ImportXlsxPlugin';
+
+export { ImportXlsxPlugin };
diff --git a/packages/sheets-plugin-import-xlsx/src/main.tsx b/packages/sheets-plugin-import-xlsx/src/main.tsx
new file mode 100644
index 0000000000..34787fd6a1
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/src/main.tsx
@@ -0,0 +1,21 @@
+import { UniverSheet } from '@univer/core';
+import { RenderEngine } from '@univer/base-render';
+import { SheetPlugin } from '@univer/base-sheets';
+import { UniverComponentSheet } from '@univer/style-universheet';
+import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';
+
+import { ImportXlsxPlugin } from './ImportXlsxPlugin';
+
+
+const uiDefaultConfigUp = {
+ container: 'universheet-demo',
+ layout: 'auto',
+};
+
+const univerSheetUp = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);
+
+univerSheetUp.installPlugin(new RenderEngine());
+univerSheetUp.installPlugin(new UniverComponentSheet());
+
+univerSheetUp.installPlugin(new SheetPlugin(uiDefaultConfigUp));
+univerSheetUp.installPlugin(new ImportXlsxPlugin());
diff --git a/packages/sheets-plugin-import-xlsx/tsconfig.json b/packages/sheets-plugin-import-xlsx/tsconfig.json
new file mode 100644
index 0000000000..fc81cbd47e
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/tsconfig.json
@@ -0,0 +1,31 @@
+{
+ "compilerOptions": {
+ "rootDir": "./",
+ "outDir": "lib",
+ "target": "ESNext",
+
+ "lib": ["ESNext", "DOM", "WebWorker"],
+ "module": "ESNext",
+ "moduleResolution": "Node", //This value is needed for Node.js.
+
+ "declaration": true,
+ "declarationDir": "./lib",
+ "declarationMap": true,
+ "sourceMap": true,
+ "resolveJsonModule": true,
+ "strict": true,
+ "allowJs": true,
+
+ "baseUrl": "./",
+ "skipLibCheck": true,
+ "esModuleInterop": true, // auto allowSyntheticDefaultImports tru
+ "suppressImplicitAnyIndexErrors": true,
+ "experimentalDecorators": true,
+ "jsx": "preserve",
+ "jsxFactory": "h",
+ "jsxFragmentFactory": "Fragment",
+ "strictPropertyInitialization": false,
+ "types": ["jest", "node", "@types/jest"]
+ },
+ "include": ["src/**/*", "test/**/*.test.(ts|tsx|js)"]
+}
diff --git a/packages/sheets-plugin-import-xlsx/tsconfig.ref.json b/packages/sheets-plugin-import-xlsx/tsconfig.ref.json
new file mode 100644
index 0000000000..0c86b2c554
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/tsconfig.ref.json
@@ -0,0 +1,7 @@
+{
+ "extends": "./tsconfig.json",
+ "include": ["src/**/*"],
+ "compilerOptions": {
+ "composite": true
+ }
+}
diff --git a/packages/sheets-plugin-import-xlsx/tsconfig.test.json b/packages/sheets-plugin-import-xlsx/tsconfig.test.json
new file mode 100644
index 0000000000..a2ac02c4ae
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/tsconfig.test.json
@@ -0,0 +1,7 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "jsx": "react-jsx",
+ "jsxImportSource": "preact"
+ }
+}
diff --git a/packages/sheets-plugin-import-xlsx/vite.config.ts b/packages/sheets-plugin-import-xlsx/vite.config.ts
new file mode 100644
index 0000000000..020ecd6209
--- /dev/null
+++ b/packages/sheets-plugin-import-xlsx/vite.config.ts
@@ -0,0 +1,44 @@
+import { defineConfig } from 'vite';
+import path from 'path';
+import preact from '@preact/preset-vite';
+import legacy from '@vitejs/plugin-legacy';
+import { name, version } from './package.json';
+
+const resolve = (url: string) => path.resolve(__dirname, url);
+
+export default defineConfig({
+ build: {
+ // lib: {
+ // entry: resolve('src/index.ts'),
+ // name: 'BaseStyleUniver',
+ // formats: ['es', 'umd'],
+ // fileName: 'index',
+ // },
+ // outDir: './lib',
+ },
+ define: {
+ pkgJson: { name, version },
+ },
+ css: {
+ modules: {
+ localsConvention: 'camelCaseOnly', // dash to camelCase conversion// .apply-color -> applyColor
+ generateScopedName: 'univer-[local]', // custom prefix class name
+ },
+ preprocessorOptions: {
+ less: {
+ javascriptEnabled: true,
+ },
+ },
+ },
+ server: {
+ port: 3103,
+ open: true, // Automatically open the app in the browser on server start.
+ },
+ plugins: [
+ preact(),
+ legacy({
+ targets: ['ie >= 11'],
+ additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
+ }),
+ ],
+});