@mescius/spread-excelio 17.0.0

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 ADDED
@@ -0,0 +1,18 @@
1
+ # SpreadJS Client-Side Excel IO
2
+
3
+ The Client-side Excel IO package is one of the plug-ins for [SpreadJS](https://developer.mescius.com/spreadjs).
4
+
5
+ Extends SpreadJS with client-side Excel import and export: XLSX to SpreadJS JSON, and SpreadJS JSON to XLSX.
6
+
7
+ For a detailed listing of SpreadJS sub-libraries and plug-ins, please see [Using SpreadJS Libraries](https://developer.mescius.com/spreadjs/docs/getstarted/modules).
8
+
9
+ ## Installation
10
+ ```sh
11
+ npm install @mescius/spread-excelio
12
+ ```
13
+
14
+ ## Getting more help
15
+ Visit the SpreadJS home page to get more information about the library:
16
+ [https://developer.mescius.com/spreadjs](https://developer.mescius.com/spreadjs)
17
+
18
+ You can ask any questions about SpreadJS using the [SpreadJS Forum](https://developer.mescius.com/forums/spreadjs).
@@ -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;