@microsoft/connected-workbooks 2.1.25 → 3.1.1-beta.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/README.md +32 -11
- package/dist/generators.js +7 -12
- package/dist/index.js +4 -30
- package/dist/main.js +464 -0
- package/dist/src/types.d.ts +54 -0
- package/dist/src/utils/constants.js +9 -3
- package/dist/src/utils/documentUtils.js +2 -1
- package/dist/src/utils/index.d.ts +8 -0
- package/dist/src/utils/mashupDocumentParser.js +5 -5
- package/dist/src/utils/pqUtils.js +4 -3
- package/dist/src/utils/tableUtils.js +12 -11
- package/dist/src/utils/xmlInnerPartsUtils.js +46 -18
- package/dist/src/utils/xmlPartsUtils.js +7 -3
- package/dist/tests/mocks/index.d.ts +3 -0
- package/dist/tests/tableUtils.test.js +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.js +6 -9
- package/dist/utils/arrayUtils.js +28 -26
- package/dist/utils/constants.js +68 -64
- package/dist/utils/documentUtils.js +88 -52
- package/dist/utils/gridUtils.js +27 -29
- package/dist/utils/htmlUtils.js +8 -10
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.js +8 -22
- package/dist/utils/mashupDocumentParser.js +128 -108
- package/dist/utils/pqUtils.js +143 -71
- package/dist/utils/tableUtils.js +140 -101
- package/dist/utils/xmlInnerPartsUtils.js +227 -144
- package/dist/utils/xmlPartsUtils.js +116 -51
- package/dist/workbookManager.d.ts +4 -3
- package/dist/workbookManager.js +168 -66
- package/dist/workbookTemplate.js +2 -5
- package/package.json +4 -2
- package/dist/gridParser.js +0 -58
- package/dist/gridUtils.js +0 -58
package/README.md
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
# Connected Workbooks
|
|
2
|
-
[](https://obilshield.visualstudio.com/ConnectedWorkbooks/_build/latest?definitionId=14&branchName=main)
|
|
3
2
|
[](https://github.com/microsoft/connected-workbooks/blob/master/LICENSE)
|
|
4
3
|
|
|
5
4
|
A pure JS library, Microsoft backed, that provides xlsx workbook generation capabilities, allowing for:
|
|
@@ -26,7 +25,7 @@ Connected Workbooks allows you to avoid "data dumps" in CSV form, providing a ri
|
|
|
26
25
|
import workbookManager from '@microsoft/connected-workbooks';
|
|
27
26
|
|
|
28
27
|
const blob = await workbookManager.generateTableWorkbookFromHtml(document.querySelector('table') as HTMLTableElement);
|
|
29
|
-
workbookManager.
|
|
28
|
+
workbookManager.openInExcelWeb(blob, "MyTable.xlsx", true /*allowTyping*/);
|
|
30
29
|
```
|
|
31
30
|
|
|
32
31
|
### 2. Export a table from raw data:
|
|
@@ -34,7 +33,7 @@ workbookManager.downloadWorkbook(blob, "MyTable.xlsx");
|
|
|
34
33
|
import workbookManager from '@microsoft/connected-workbooks';
|
|
35
34
|
|
|
36
35
|
const grid = {
|
|
37
|
-
config: { promoteHeaders:true, adjustColumnNames:true }
|
|
36
|
+
config: { promoteHeaders:true, adjustColumnNames:true },
|
|
38
37
|
data: [
|
|
39
38
|
["Product", "Price", "InStock", "Category", "Date"],
|
|
40
39
|
["Widget A", 19.99, true, "Electronics", "10/26/2024"],
|
|
@@ -45,17 +44,23 @@ const grid = {
|
|
|
45
44
|
]
|
|
46
45
|
};
|
|
47
46
|
const blob = await workbookManager.generateTableWorkbookFromGrid(grid);
|
|
48
|
-
workbookManager.
|
|
47
|
+
workbookManager.openInExcelWeb(blob, "MyTable.xlsx", true /*allowTyping*/);
|
|
49
48
|
```
|
|
50
49
|
<img width="281" alt="image" src="https://github.com/microsoft/connected-workbooks/assets/7674478/b91e5d69-8444-4a19-a4b0-3fd721e5576f">
|
|
51
50
|
|
|
52
51
|
### 3. Control Document Properties:
|
|
53
52
|
```typescript
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
const blob = await workbookManager.generateTableWorkbookFromHtml(
|
|
54
|
+
document.querySelector('table') as HTMLTableElement, {
|
|
55
|
+
docProps: {
|
|
56
|
+
createdBy: 'John Doe',
|
|
57
|
+
lastModifiedBy: 'Jane Doe',
|
|
58
|
+
description: 'This is a sample table'
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
);
|
|
57
62
|
|
|
58
|
-
|
|
63
|
+
workbookManager.downloadWorkbook(blob, "MyTable.xlsx");
|
|
59
64
|
```
|
|
60
65
|

|
|
61
66
|
|
|
@@ -68,7 +73,9 @@ const blob = await workbookManager.generateSingleQueryWorkbook({
|
|
|
68
73
|
Source = {1..10} \
|
|
69
74
|
in \
|
|
70
75
|
Source',
|
|
71
|
-
refreshOnOpen: true
|
|
76
|
+
refreshOnOpen: true
|
|
77
|
+
});
|
|
78
|
+
|
|
72
79
|
workbookManager.downloadWorkbook(blob, "MyConnectedWorkbook.xlsx");
|
|
73
80
|
```
|
|
74
81
|

|
|
@@ -126,7 +133,7 @@ async function `generateTableWorkbookFromHtml`: `Promise<Blob>`
|
|
|
126
133
|
|Parameter | Type | Required | Description |
|
|
127
134
|
|--- |--- |--- |--- |
|
|
128
135
|
| htmlTable | HTMLTableElement | __required__ | Initial data loaded to workbook |
|
|
129
|
-
|
|
|
136
|
+
| fileConfigs | [FileConfigs](#fileconfigs) | optional | Custom file configurations |
|
|
130
137
|
|
|
131
138
|
#### 3. Generate a table workbook with raw data
|
|
132
139
|
```typescript
|
|
@@ -136,7 +143,20 @@ async function `generateTableWorkbookFromGrid`: `Promise<Blob>`
|
|
|
136
143
|
|Parameter | Type | Required | Description |
|
|
137
144
|
|--- |--- |--- |--- |
|
|
138
145
|
| grid | [Grid](#grid) | __required__ | Initial data loaded to workbook |
|
|
139
|
-
|
|
|
146
|
+
| fileConfigs | [FileConfigs](#fileconfigs) | optional | Custom file configurations |
|
|
147
|
+
|
|
148
|
+
#### 3. Open the created workbook in excel for the web
|
|
149
|
+
```typescript
|
|
150
|
+
async function `openInExcelWeb`: `Promise<void>`
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
⭐ This API is supported only for an HTTPS domain.
|
|
154
|
+
|
|
155
|
+
|Parameter | Type | Required | Description |
|
|
156
|
+
|--- |--- |--- |--- |
|
|
157
|
+
| blob | [Blob](https://developer.mozilla.org/docs/Web/API/Blob) | __required__ | Initial data loaded to workbook |
|
|
158
|
+
| filename | string | optional | Custom the opened file name |
|
|
159
|
+
| allowTyping | boolean | optional | allow user editing (typing) |
|
|
140
160
|
</br>
|
|
141
161
|
|
|
142
162
|
### Types
|
|
@@ -165,6 +185,7 @@ async function `generateTableWorkbookFromGrid`: `Promise<Blob>`
|
|
|
165
185
|
|---|---|---|---|
|
|
166
186
|
| templateFile | File | optional | Custom Excel workbook |
|
|
167
187
|
| docProps | [DocProps](#docprops) | optional | Custom workbook properties |
|
|
188
|
+
| hostName | string | optional | specify the host creator name |
|
|
168
189
|
|
|
169
190
|
#### DocProps
|
|
170
191
|
|Parameter | Type | Required
|
package/dist/generators.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright (c) Microsoft Corporation.
|
|
3
2
|
// Licensed under the MIT license.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
${query};`;
|
|
12
|
-
exports.generateSingleQueryMashup = generateSingleQueryMashup;
|
|
13
|
-
const generateCustomXmlFilePath = (i) => `customXml/item${i}.xml`;
|
|
14
|
-
exports.generateCustomXmlFilePath = generateCustomXmlFilePath;
|
|
3
|
+
export var generateMashupXMLTemplate = function (base64) {
|
|
4
|
+
return "<?xml version=\"1.0\" encoding=\"utf-16\"?><DataMashup xmlns=\"http://schemas.microsoft.com/DataMashup\">".concat(base64, "</DataMashup>");
|
|
5
|
+
};
|
|
6
|
+
export var generateSingleQueryMashup = function (queryName, query) {
|
|
7
|
+
return "section Section1;\n \n shared #\"".concat(queryName, "\" = \n ").concat(query, ";");
|
|
8
|
+
};
|
|
9
|
+
export var generateCustomXmlFilePath = function (i) { return "customXml/item".concat(i, ".xml"); };
|
package/dist/index.js
CHANGED
|
@@ -1,32 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright (c) Microsoft Corporation.
|
|
3
2
|
// Licensed under the MIT license.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
-
}
|
|
10
|
-
Object.defineProperty(o, k2, desc);
|
|
11
|
-
}) : (function(o, m, k, k2) {
|
|
12
|
-
if (k2 === undefined) k2 = k;
|
|
13
|
-
o[k2] = m[k];
|
|
14
|
-
}));
|
|
15
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
-
}) : function(o, v) {
|
|
18
|
-
o["default"] = v;
|
|
19
|
-
});
|
|
20
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
-
if (mod && mod.__esModule) return mod;
|
|
22
|
-
var result = {};
|
|
23
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
-
__setModuleDefault(result, mod);
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.DataTypes = void 0;
|
|
29
|
-
const workbookManager = __importStar(require("./workbookManager"));
|
|
30
|
-
const types_1 = require("./types");
|
|
31
|
-
Object.defineProperty(exports, "DataTypes", { enumerable: true, get: function () { return types_1.DataTypes; } });
|
|
32
|
-
exports.default = workbookManager;
|
|
3
|
+
import * as workbookManager from "./workbookManager";
|
|
4
|
+
import { DataTypes } from "./types";
|
|
5
|
+
export { DataTypes };
|
|
6
|
+
export default workbookManager;
|