@microsoft/connected-workbooks 3.0.0 → 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 +17 -4
- 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/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 +9 -8
- package/dist/src/utils/xmlInnerPartsUtils.js +18 -17
- package/dist/tests/mocks/index.d.ts +3 -0
- 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 -68
- 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 +228 -172
- package/dist/utils/xmlPartsUtils.js +116 -55
- package/dist/workbookManager.d.ts +1 -0
- package/dist/workbookManager.js +168 -72
- package/dist/workbookTemplate.js +2 -5
- package/package.json +2 -1
- 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,7 +44,7 @@ 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
|
|
|
@@ -145,6 +144,19 @@ async function `generateTableWorkbookFromGrid`: `Promise<Blob>`
|
|
|
145
144
|
|--- |--- |--- |--- |
|
|
146
145
|
| grid | [Grid](#grid) | __required__ | Initial data loaded to workbook |
|
|
147
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) |
|
|
148
160
|
</br>
|
|
149
161
|
|
|
150
162
|
### Types
|
|
@@ -173,6 +185,7 @@ async function `generateTableWorkbookFromGrid`: `Promise<Blob>`
|
|
|
173
185
|
|---|---|---|---|
|
|
174
186
|
| templateFile | File | optional | Custom Excel workbook |
|
|
175
187
|
| docProps | [DocProps](#docprops) | optional | Custom workbook properties |
|
|
188
|
+
| hostName | string | optional | specify the host creator name |
|
|
176
189
|
|
|
177
190
|
#### DocProps
|
|
178
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;
|