@office-view-suite/viewer-excel 0.2.0 → 0.2.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/dist/asset-manifest.json +2 -2
- package/dist/assets/excel/excel_view_rs_bg.wasm +0 -0
- package/dist/index.js +518 -369
- package/dist/types/core/format.d.ts +4 -6
- package/dist/types/core/layout.d.ts +15 -1
- package/dist/types/core/render.d.ts +2 -2
- package/dist/types/core/styles.d.ts +3 -1
- package/dist/types/core/types.d.ts +38 -0
- package/dist/types/core/virtual.d.ts +1 -0
- package/package.json +2 -2
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
export declare function formatValue(value: string, numfmt?: string): string;
|
|
1
|
+
type ValueType = 'number' | 'string' | 'boolean' | 'error' | 'date' | 'empty';
|
|
2
|
+
export declare function numberFormatColor(value: string, format?: string, kind?: ValueType): string | undefined;
|
|
3
|
+
export declare function formatValue(value: string, numfmt?: string, kind?: ValueType, date1904?: boolean): string;
|
|
4
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExcelSheet } from './types';
|
|
1
|
+
import type { ExcelImage, ExcelShape, ExcelSheet } from './types';
|
|
2
2
|
/** One-based spreadsheet coordinates; end coordinates are inclusive. */
|
|
3
3
|
export interface CellRange {
|
|
4
4
|
c1: number;
|
|
@@ -35,3 +35,17 @@ export interface AxisWindow {
|
|
|
35
35
|
last: number;
|
|
36
36
|
}
|
|
37
37
|
export declare function visibleWindow(axis: Axis, start: number, length: number, minimum?: number, overscan?: number): AxisWindow;
|
|
38
|
+
/** Drawing end markers are points inside the terminal cell, not inclusive cell ranges. */
|
|
39
|
+
export declare function drawingBounds(source: ExcelImage | ExcelShape, columns: Axis, rows: Axis): {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
};
|
|
45
|
+
/** Visual image bounds for culling/scroll reach; the original anchor stays unchanged. */
|
|
46
|
+
export declare function imageVisualBounds(box: {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
width: number;
|
|
50
|
+
height: number;
|
|
51
|
+
}, rotation?: number): typeof box;
|
|
@@ -8,8 +8,8 @@ export interface RenderStats {
|
|
|
8
8
|
shapes: number;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* Mount only the active worksheet.
|
|
12
|
-
* large sheets
|
|
11
|
+
* Mount only the active visible worksheet. Both rendering paths share source dimensions;
|
|
12
|
+
* large sheets mount a window bounded by the scroll viewport.
|
|
13
13
|
*/
|
|
14
14
|
export declare function renderExcelInto(host: HTMLElement, doc: ExcelDoc, onError?: (error: Error) => void, onContentChange?: () => void): {
|
|
15
15
|
stats: RenderStats;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
export declare const CELL_LINE_HEIGHT = 1.25;
|
|
2
|
+
export declare function cellFontFamily(name: string | undefined, inherited: string): string;
|
|
1
3
|
/** excel-view 渲染样式:注入 Shadow DOM */
|
|
2
|
-
export declare const SHADOW_CSS = "\n:host { display: block; }\n\n.workbook { display: flex; flex-direction: column; gap: 12px; width: 100%; }\n.workbook--bounded { height: var(--office-excel-workbook-height); min-height: 0; }\n.workbook--bounded > .sheet-tabs { flex: 0 0 auto; }\n.workbook--bounded .sheet-pages, .workbook--bounded .sheet:not([hidden]) { display: flex; flex: 1 1 0; flex-direction: column; min-height: 0; }\n.workbook--bounded .grid-wrap { flex: 1 1 0; min-height: 0; max-height: none; }\n.sheet-tabs { position: sticky; top: 0; z-index: 20; display: flex; gap: 0; overflow-x: auto; padding: 6px 0 0; background: #f6f7f9; border-bottom: 1px solid #c9d0d7; }\n.sheet-tab { flex: 0 0 auto; min-height: 34px; padding: 6px 14px; border: 0; border-right: 1px solid #d7dce1; border-bottom: 2px solid transparent; background: #eef1f4; color: #30363d; cursor: pointer; }\n.sheet-tab[aria-selected=\"true\"] { background: #fff; border-bottom-color: #217346; color: #111; font-weight: 600; }\n.sheet[hidden] { display: none; }\n\n.grid-wrap { overflow: auto; max-height: 63vh; max-width: var(--office-viewer-viewport-width, none); box-sizing: border-box; background: #fff; border: 1px solid #d0d7de; border-radius: 0; }\n.grid { display: grid; gap: 0; width: max-content; zoom: var(--office-excel-scale, 1);\n border-left: 1px solid #e4e8ec; border-top: 1px solid #e4e8ec; }\n\n.cell {\n border-right: 1px solid #e4e8ec;\n border-bottom: 1px solid #e4e8ec;\n padding: 3px 8px;\n font-size: 14px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n color: #111418;\n background: #fff;\n}\n.frozen-row, .frozen-column { position: sticky; z-index: 5; }\n.frozen-corner { z-index: 6; }\n.virtual-grid { display: block; position: relative; overflow: clip; }\n.virtual-window { position: absolute; overflow: hidden; }\n.virtual-pane { position: absolute; overflow: hidden; background: #fff; }\n.virtual-pane > .cell, .virtual-pane > .sheet-image, .virtual-pane > .sheet-shape {\n position: absolute; box-sizing: border-box;\n}\n.sheet-image { position: relative; z-index: 8; align-self: start; justify-self: start; pointer-events: none; overflow: hidden; }\n.sheet-image img { display: block; width: 100%; height: 100%; object-fit: contain; }\n.sheet-image-cell { width: 100%; height: 100%; align-self: stretch; justify-self: stretch; padding: 2px; box-sizing: border-box; background: #fff; }\n.sheet-shape {\n position: relative;\n z-index: 9;\n box-sizing: border-box;\n align-self: stretch;\n justify-self: stretch;\n min-width: 1px;\n min-height: 1px;\n padding: 4px 6px;\n border: 1px solid transparent;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n pointer-events: none;\n white-space: pre-wrap;\n}\n.sheet-shape-paragraph { width: 100%; text-align: center; line-height: 1.2; }\n.sheet-shape-line { align-self: center; min-height: 0; height: 0 !important; padding: 0; border: 0; border-top: 1px solid #666; background: transparent !important; }\n\n@media print { .grid-wrap { overflow: visible; } }\n";
|
|
4
|
+
export declare const SHADOW_CSS = "\n:host { display: block; }\n\n.workbook { display: flex; flex-direction: column; gap: 12px; width: 100%; }\n.workbook--bounded { height: var(--office-excel-workbook-height); min-height: 0; }\n.workbook--bounded > .sheet-tabs { flex: 0 0 auto; }\n.workbook--bounded .sheet-pages, .workbook--bounded .sheet:not([hidden]) { display: flex; flex: 1 1 0; flex-direction: column; min-height: 0; }\n.workbook--bounded .grid-wrap { flex: 1 1 0; min-height: 0; max-height: none; }\n.sheet-tabs { position: sticky; top: 0; z-index: 20; display: flex; gap: 0; overflow-x: auto; padding: 6px 0 0; background: #f6f7f9; border-bottom: 1px solid #c9d0d7; }\n.sheet-tab { flex: 0 0 auto; min-height: 34px; padding: 6px 14px; border: 0; border-right: 1px solid #d7dce1; border-bottom: 2px solid transparent; background: #eef1f4; color: #30363d; cursor: pointer; }\n.sheet-tab[aria-selected=\"true\"] { background: #fff; border-bottom-color: #217346; color: #111; font-weight: 600; }\n.sheet[hidden] { display: none; }\n\n.grid-wrap { overflow: auto; max-height: 63vh; max-width: var(--office-viewer-viewport-width, none); box-sizing: border-box; background: #fff; border: 1px solid #d0d7de; border-radius: 0; }\n.grid { position: relative; display: grid; gap: 0; width: max-content; zoom: var(--office-excel-scale, 1);\n border-left: 1px solid #e4e8ec; border-top: 1px solid #e4e8ec; }\n\n.grid--no-lines { border-color: transparent; }\n.grid--no-lines .cell { border-color: transparent; }\n.cell-content { width: 100%; min-width: 0; }\n.cell {\n display: flex;\n flex-direction: column;\n justify-content: flex-end;\n box-sizing: border-box;\n border-right: 1px solid #e4e8ec;\n border-bottom: 1px solid #e4e8ec;\n padding: 3px 8px;\n font-size: 14px;\n line-height: 1.25;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n color: #111418;\n background: #fff;\n}\n.frozen-row, .frozen-column { position: sticky; z-index: 5; }\n.frozen-corner { z-index: 6; }\n.virtual-grid { display: block; position: relative; overflow: clip; }\n.virtual-window { position: absolute; overflow: hidden; }\n.virtual-pane { position: absolute; overflow: hidden; background: #fff; }\n.virtual-pane > .cell, .virtual-pane > .sheet-image, .virtual-pane > .sheet-shape {\n position: absolute; box-sizing: border-box;\n}\n.sheet-image { position: relative; z-index: 8; align-self: start; justify-self: start; pointer-events: none; overflow: hidden; }\n.sheet-image img { display: block; width: 100%; height: 100%; object-fit: contain; }\n.sheet-image-cell { width: 100%; height: 100%; align-self: stretch; justify-self: stretch; padding: 2px; box-sizing: border-box; background: #fff; }\n.sheet-shape {\n position: relative;\n z-index: 9;\n box-sizing: border-box;\n align-self: stretch;\n justify-self: stretch;\n min-width: 1px;\n min-height: 1px;\n padding: 4px 6px;\n border: 1px solid transparent;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n pointer-events: none;\n white-space: pre-wrap;\n}\n.sheet-shape-paragraph { width: 100%; text-align: center; line-height: 1.2; }\n.sheet-shape-line { align-self: center; min-height: 0; height: 0 !important; padding: 0; border: 0; border-top: 1px solid #666; background: transparent !important; }\n\n@media print { .grid-wrap { overflow: visible; } }\n";
|
|
@@ -1,19 +1,30 @@
|
|
|
1
1
|
/** excel-view-rs(wasm shim)输出的文档模型 */
|
|
2
2
|
export interface ExcelDoc {
|
|
3
3
|
sheets: ExcelSheet[];
|
|
4
|
+
date1904?: boolean;
|
|
5
|
+
activeTab?: number;
|
|
4
6
|
}
|
|
5
7
|
export interface ExcelSheet {
|
|
6
8
|
name: string;
|
|
9
|
+
/** Missing state means visible; hidden sheets remain in the parsed workbook. */
|
|
10
|
+
state?: 'visible' | 'hidden' | 'veryHidden';
|
|
11
|
+
date1904?: boolean;
|
|
12
|
+
showGridLines?: boolean;
|
|
13
|
+
defaultColWidth?: number;
|
|
14
|
+
defaultRowHeight?: number;
|
|
7
15
|
highestCol: number;
|
|
8
16
|
highestRow: number;
|
|
9
17
|
merges: string[];
|
|
10
18
|
colWidths: {
|
|
11
19
|
col: number;
|
|
12
20
|
width: number;
|
|
21
|
+
hidden?: boolean;
|
|
13
22
|
}[];
|
|
14
23
|
rowHeights: {
|
|
15
24
|
row: number;
|
|
16
25
|
height: number;
|
|
26
|
+
hidden?: boolean;
|
|
27
|
+
customHeight?: boolean;
|
|
17
28
|
}[];
|
|
18
29
|
cells: ExcelCell[];
|
|
19
30
|
images: ExcelImage[];
|
|
@@ -25,6 +36,9 @@ export interface ExcelCell {
|
|
|
25
36
|
col: number;
|
|
26
37
|
row: number;
|
|
27
38
|
value: string;
|
|
39
|
+
valueType?: 'number' | 'string' | 'boolean' | 'error' | 'date' | 'empty';
|
|
40
|
+
cachedValuePresent?: boolean;
|
|
41
|
+
date1904?: boolean;
|
|
28
42
|
formula?: string;
|
|
29
43
|
fontName?: string;
|
|
30
44
|
fontSize?: number;
|
|
@@ -40,6 +54,10 @@ export interface ExcelCell {
|
|
|
40
54
|
borderRight?: string;
|
|
41
55
|
borderTop?: string;
|
|
42
56
|
borderBottom?: string;
|
|
57
|
+
borderLeftColor?: string;
|
|
58
|
+
borderRightColor?: string;
|
|
59
|
+
borderTopColor?: string;
|
|
60
|
+
borderBottomColor?: string;
|
|
43
61
|
numfmt?: string;
|
|
44
62
|
richText?: ExcelRichTextRun[];
|
|
45
63
|
}
|
|
@@ -62,6 +80,21 @@ export interface ExcelImage {
|
|
|
62
80
|
data: string;
|
|
63
81
|
name: string;
|
|
64
82
|
fitCell: boolean;
|
|
83
|
+
offsetXPx?: number;
|
|
84
|
+
offsetYPx?: number;
|
|
85
|
+
toOffsetXPx?: number;
|
|
86
|
+
toOffsetYPx?: number;
|
|
87
|
+
/** DrawingML source insets as fractions; negative values extend into transparent space. */
|
|
88
|
+
crop?: {
|
|
89
|
+
left: number;
|
|
90
|
+
top: number;
|
|
91
|
+
right: number;
|
|
92
|
+
bottom: number;
|
|
93
|
+
};
|
|
94
|
+
/** Clockwise degrees, applied after flips about the anchor's center. */
|
|
95
|
+
rotation?: number;
|
|
96
|
+
flipH?: boolean;
|
|
97
|
+
flipV?: boolean;
|
|
65
98
|
}
|
|
66
99
|
export interface ExcelShape {
|
|
67
100
|
col: number;
|
|
@@ -72,6 +105,11 @@ export interface ExcelShape {
|
|
|
72
105
|
heightPx?: number;
|
|
73
106
|
offsetXPx: number;
|
|
74
107
|
offsetYPx: number;
|
|
108
|
+
toOffsetXPx?: number;
|
|
109
|
+
toOffsetYPx?: number;
|
|
110
|
+
rotation?: number;
|
|
111
|
+
flipH?: boolean;
|
|
112
|
+
flipV?: boolean;
|
|
75
113
|
name: string;
|
|
76
114
|
geometry: string;
|
|
77
115
|
fill?: string;
|
|
@@ -34,5 +34,6 @@ interface Renderers {
|
|
|
34
34
|
image(source: ExcelImage): HTMLElement;
|
|
35
35
|
shape(source: ExcelShape): HTMLElement;
|
|
36
36
|
}
|
|
37
|
+
export declare function sheetLayout(sheet: ExcelSheet, owner: Document, family: string): SheetLayout;
|
|
37
38
|
export declare function renderVirtualSheet(sheet: ExcelSheet, element: HTMLElement, viewport: HTMLElement, grid: HTMLElement, cache: VirtualCache, renderers: Renderers, onError?: (error: Error) => void, onContentChange?: () => void): SheetView;
|
|
38
39
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@office-view-suite/viewer-excel",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dist"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@office-view-suite/viewer-core": "0.2.
|
|
22
|
+
"@office-view-suite/viewer-core": "0.2.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"typescript": "^5.6.0",
|