@grapecity-software/spread-excelio 17.0.2
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 +17 -0
- package/dist/gc.spread.excelio.d.ts +122 -0
- package/dist/gc.spread.excelio.min.js +49 -0
- package/index.d.ts +3 -0
- package/index.js +1 -0
- package/package.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# SpreadJS Client-Side Excel IO
|
|
2
|
+
|
|
3
|
+
客户端 Excel IO 软件包是 [SpreadJS](https://www.grapecity.com.cn/developer/spreadjs) 的插件之一。
|
|
4
|
+
|
|
5
|
+
它通过在客户端扩展 SpreadJS,实现了 Excel 的导入和导出:XLSX 格式转换为 SpreadJS JSON 格式,以及 SpreadJS JSON 格式转换为 XLSX 格式。
|
|
6
|
+
|
|
7
|
+
有关 SpreadJS 模块和插件的详细列表,请参见 [SpreadJS 组件库](https://demo.grapecity.com.cn/spreadjs/help/docs/getstarted/modules)
|
|
8
|
+
|
|
9
|
+
## 安装模块/插件
|
|
10
|
+
```sh
|
|
11
|
+
npm install @grapecity-software/spread-excelio
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## 获取更多帮助
|
|
15
|
+
想需要获取更多产品信息,请浏览 [SpreadJS 主页](https://www.grapecity.com.cn/developer/spreadjs)
|
|
16
|
+
|
|
17
|
+
您可以在论坛中提出任何您使用产品过程中遇到的问题: [技术支持论坛](https://gcdn.grapecity.com.cn/showforum-232-1.html)
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
declare module GC{
|
|
2
|
+
module Spread{
|
|
3
|
+
module Excel{
|
|
4
|
+
|
|
5
|
+
export class IO{
|
|
6
|
+
/**
|
|
7
|
+
* Represents an excel import and export class.
|
|
8
|
+
* @class
|
|
9
|
+
*/
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Imports an excel file.
|
|
13
|
+
* @param {Blob} file The excel file.
|
|
14
|
+
* @param {function} successCallBack Call this function after successfully loading the file. `function (json) { }`.
|
|
15
|
+
* @param {function} errorCallBack Call this function if an error occurs. The exception parameter object structure `{ errorCode: GC.Spread.Excel.IO.ErrorCode, errorMessage: string}`.
|
|
16
|
+
* @param {GC.Spread.Excel.IO.OpenOptions} options The options for import excel.
|
|
17
|
+
* @returns {void}
|
|
18
|
+
* @example
|
|
19
|
+
* ```
|
|
20
|
+
* var workbook = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
|
|
21
|
+
* var excelIO = new GC.Spread.Excel.IO();
|
|
22
|
+
* var excelFile = document.getElementById("fileDemo").files[0];
|
|
23
|
+
* excelIO.open(excelFile, function (json) {
|
|
24
|
+
* workbook.fromJSON(json);
|
|
25
|
+
* }, function (e) {
|
|
26
|
+
* console.log(e);
|
|
27
|
+
* }, {
|
|
28
|
+
* password: "password",
|
|
29
|
+
* importPictureAsFloatingObject: false
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
open(file: Blob, successCallBack: Function, errorCallBack?: Function, options?: GC.Spread.Excel.IO.OpenOptions): void;
|
|
34
|
+
/**
|
|
35
|
+
* Register a unknown max digit width info to ExcelIO.
|
|
36
|
+
* @param {string} fontFamily The font family of default style's font.
|
|
37
|
+
* @param {number} fontSize The font size of default style's font(in point).
|
|
38
|
+
* @param {number} maxDigitWidth The max digit width of default style's font.
|
|
39
|
+
* @returns {void}
|
|
40
|
+
*/
|
|
41
|
+
registerMaxDigitWidth(fontFamily: string, fontSize: number, maxDigitWidth: number): void;
|
|
42
|
+
/**
|
|
43
|
+
* Creates and saves an excel file with the SpreadJS json.
|
|
44
|
+
* @param {object} json The spread sheets json object, or string.
|
|
45
|
+
* @param {function} successCallBack Call this function after successfully exporting the file. `function (blob) { }`.
|
|
46
|
+
* @param {function} errorCallBack Call this function if an error occurs. The exception parameter object structure `{ errorCode: GC.Spread.Excel.IO.ErrorCode, errorMessage: string}`.
|
|
47
|
+
* @param {GC.Spread.Excel.IO.SaveOptions} options The options for export excel.
|
|
48
|
+
* @returns {void}
|
|
49
|
+
* @example
|
|
50
|
+
* ```
|
|
51
|
+
* var workbook = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
|
|
52
|
+
* var excelIO = new GC.Spread.Excel.IO();
|
|
53
|
+
* var json = JSON.stringify(workbook.toJSON());
|
|
54
|
+
* excelIO.save(json, function (blob) {
|
|
55
|
+
* saveAs(blob, fileName); //saveAs is from FileSaver.
|
|
56
|
+
* }, function (e) {
|
|
57
|
+
* console.log(e);
|
|
58
|
+
* }, {
|
|
59
|
+
* password: "password",
|
|
60
|
+
* xlsxStrictMode: false
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
save(json: string | object, successCallBack: Function, errorCallBack?: Function, options?: GC.Spread.Excel.IO.SaveOptions): void;
|
|
65
|
+
}
|
|
66
|
+
module IO{
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @typedef GC.Spread.Excel.IO.OpenOptions - The options for import excel.
|
|
70
|
+
* @property {string} password the excel file's password.
|
|
71
|
+
* @property {boolean} importPictureAsFloatingObject import picture as floatingObject instead of shape.
|
|
72
|
+
*/
|
|
73
|
+
export type OpenOptions =
|
|
74
|
+
{
|
|
75
|
+
password?: string;
|
|
76
|
+
importPictureAsFloatingObject?: boolean;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @typedef GC.Spread.Excel.IO.SaveOptions - The options for export excel.
|
|
82
|
+
* @property {string} password the excel file's password.
|
|
83
|
+
* @property {boolean} xlsxStrictMode the mode of exporting process, the non-strict mode may reduce the export size. Default is true.
|
|
84
|
+
*/
|
|
85
|
+
export type SaveOptions =
|
|
86
|
+
{
|
|
87
|
+
password?: string;
|
|
88
|
+
xlsxStrictMode?: boolean;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Specifies the excel io error code.
|
|
93
|
+
* @enum {number}
|
|
94
|
+
*/
|
|
95
|
+
export enum ErrorCode{
|
|
96
|
+
/**
|
|
97
|
+
* File read and write exception.
|
|
98
|
+
*/
|
|
99
|
+
fileIOError= 0,
|
|
100
|
+
/**
|
|
101
|
+
* Incorrect file format.
|
|
102
|
+
*/
|
|
103
|
+
fileFormatError= 1,
|
|
104
|
+
/**
|
|
105
|
+
* The Excel file cannot be opened because the workbook/worksheet is password protected.
|
|
106
|
+
*/
|
|
107
|
+
noPassword= 2,
|
|
108
|
+
/**
|
|
109
|
+
* The specified password is incorrect.
|
|
110
|
+
*/
|
|
111
|
+
invalidPassword= 3
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export = GC.Spread.Excel;
|