exportExcel支持自定义表头

This commit is contained in:
wenjiarui 2023-06-26 13:41:39 +08:00
parent 28b44dd68c
commit 96637ffac8
2 changed files with 9 additions and 7 deletions

7
lib/types/Port.d.ts vendored
View File

@ -1,12 +1,13 @@
import { AsyncContext } from "../store/AsyncRowStore"; import { AsyncContext } from "../store/AsyncRowStore";
import { EntityDict } from "./Entity"; import { EntityDict } from "./Entity";
export declare type Exportation<ED extends EntityDict, T extends keyof ED, K extends string> = { export declare type Exportation<ED extends EntityDict, T extends keyof ED> = {
name: string; name: string;
id: string; id: string;
entity: T; entity: T;
projection: ED[T]['Selection']['data']; projection: ED[T]['Selection']['data'];
headers: K[]; headers?: string[];
fn: (data: ED[T]['Schema']) => Partial<Record<K, string | number | boolean | null>>; makeHeaders?: (dataList: Partial<ED[T]['Schema']>[]) => string[];
fn: (data: ED[T]['Schema']) => Partial<Record<string, string | number | boolean | null>>;
}; };
export declare type Importation<ED extends EntityDict, T extends keyof ED, K extends string> = { export declare type Importation<ED extends EntityDict, T extends keyof ED, K extends string> = {
name: string; name: string;

View File

@ -2,13 +2,14 @@ import { AsyncContext } from "../store/AsyncRowStore";
import { SyncContext } from "../store/SyncRowStore"; import { SyncContext } from "../store/SyncRowStore";
import { EntityDict } from "./Entity"; import { EntityDict } from "./Entity";
export type Exportation<ED extends EntityDict, T extends keyof ED, K extends string> = { export type Exportation<ED extends EntityDict, T extends keyof ED> = {
name: string; name: string;
id: string; id: string;
entity: T; entity: T;
projection: ED[T]['Selection']['data']; projection: ED[T]['Selection']['data'];
headers: K[]; headers?: string[];
fn: (data: ED[T]['Schema']) => Partial<Record<K, string | number | boolean | null>>; makeHeaders?: (dataList: Partial<ED[T]['Schema']>[]) => string[];
fn: (data: ED[T]['Schema']) => Partial<Record<string, string | number | boolean | null>>;
}; };
export type Importation<ED extends EntityDict, T extends keyof ED, K extends string> = { export type Importation<ED extends EntityDict, T extends keyof ED, K extends string> = {
@ -17,5 +18,5 @@ export type Importation<ED extends EntityDict, T extends keyof ED, K extends str
entity: T; entity: T;
headers: K[]; headers: K[];
// 解析过程中如果出错请抛出OakImportDataParseException异常 // 解析过程中如果出错请抛出OakImportDataParseException异常
fn: (data: Partial<Record<K, string | number | boolean>>[], context: AsyncContext<ED>, option?: Record<string, any> ) => Promise<ED[T]['CreateMulti']['data']>; fn: (data: Partial<Record<K, string | number | boolean>>[], context: AsyncContext<ED>, option?: Record<string, any>) => Promise<ED[T]['CreateMulti']['data']>;
}; };