@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 CHANGED
@@ -1,5 +1,4 @@
1
1
  # Connected Workbooks
2
- [![Build Status](https://obilshield.visualstudio.com/ConnectedWorkbooks/_apis/build/status/microsoft.connected-workbooks?branchName=main)](https://obilshield.visualstudio.com/ConnectedWorkbooks/_build/latest?definitionId=14&branchName=main)
3
2
  [![License](https://img.shields.io/github/license/microsoft/connected-workbooks)](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.downloadWorkbook(blob, "MyTable.xlsx");
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.downloadWorkbook(blob, "MyTable.xlsx");
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
- const blob = await workbookManager.generateTableWorkbookFromHtml(
55
- document.querySelector('table') as HTMLTableElement,
56
- {createdBy: 'John Doe', lastModifiedBy: 'Jane Doe', description: 'This is a sample table'});
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
- workbookManager.downloadWorkbook(blob, "MyTable.xlsx");
63
+ workbookManager.downloadWorkbook(blob, "MyTable.xlsx");
59
64
  ```
60
65
  ![image](https://github.com/microsoft/connected-workbooks/assets/7674478/c267c9eb-6367-419d-832d-5a835c7683f9)
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
  ![image](https://github.com/microsoft/connected-workbooks/assets/7674478/57bd986c-6309-4963-8d86-911ccf496c3f)
@@ -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
- | docProps | [DocProps](#docprops) | optional | Custom workbook properties |
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
- | docProps | [DocProps](#docprops) | optional | Custom workbook properties |
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
@@ -1,14 +1,9 @@
1
- "use strict";
2
1
  // Copyright (c) Microsoft Corporation.
3
2
  // Licensed under the MIT license.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.generateCustomXmlFilePath = exports.generateSingleQueryMashup = exports.generateMashupXMLTemplate = void 0;
6
- const generateMashupXMLTemplate = (base64) => `<?xml version="1.0" encoding="utf-16"?><DataMashup xmlns="http://schemas.microsoft.com/DataMashup">${base64}</DataMashup>`;
7
- exports.generateMashupXMLTemplate = generateMashupXMLTemplate;
8
- const generateSingleQueryMashup = (queryName, query) => `section Section1;
9
-
10
- shared #"${queryName}" =
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
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
- if (k2 === undefined) k2 = k;
6
- var desc = Object.getOwnPropertyDescriptor(m, k);
7
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
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;