@microsoft/connected-workbooks 3.4.1 → 3.4.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 CHANGED
@@ -10,7 +10,11 @@
10
10
  **Open your data directly in Excel for the Web with zero installation** - A JavaScript library that converts web tables and data into interactive Excel workbooks with Power Query integration and custom branded templates
11
11
 
12
12
  <div align="center">
13
- <img src="./assets/template example.gif" alt="Connected Workbooks Demo" >
13
+ <a href="https://aka.ms/OpenInExcelREADME" target="_blank">
14
+ <img src="./assets/template example.gif" alt="Connected Workbooks Demo - Click to watch video" >
15
+ <br/>
16
+ <strong>📺 Watch the video tutorial</strong>
17
+ </a>
14
18
  </div>
15
19
 
16
20
 
@@ -79,8 +83,15 @@ const blob = await workbookManager.generateTableWorkbookFromHtml(
79
83
  document.querySelector('table') as HTMLTableElement
80
84
  );
81
85
 
82
- // Open in Excel for the Web with editing enabled
83
- workbookManager.openInExcelWeb(blob, "QuickExport.xlsx", true);
86
+ // Open in Excel for the Web
87
+ // Edit mode with full editing capabilities (default)
88
+ workbookManager.openInExcelWeb(blob, "QuickExport.xlsx");
89
+
90
+ // View mode with typing disabled
91
+ workbookManager.openInExcelWeb(blob, "QuickExport.xlsx", false, false);
92
+
93
+ // View mode with typing enabled
94
+ workbookManager.openInExcelWeb(blob, "QuickExport.xlsx", true, false);
84
95
  ```
85
96
 
86
97
  ### 📊 **Smart Data Formatting**
@@ -309,9 +320,9 @@ Open workbooks directly in Excel for the Web.
309
320
 
310
321
  ```typescript
311
322
  async function openInExcelWeb(
312
- blob: Blob,
313
- filename?: string,
314
- allowTyping?: boolean
323
+ blob: Blob,
324
+ filename?: string,
325
+ allowEdit?: boolean
315
326
  ): Promise<void>
316
327
  ```
317
328
 
@@ -319,7 +330,7 @@ async function openInExcelWeb(
319
330
  |-----------|------|----------|-------------|
320
331
  | `blob` | `Blob` | ✅ **Required** | Generated workbook |
321
332
  | `filename` | `string` | Optional | Custom filename |
322
- | `allowTyping` | `boolean` | Optional | Enable editing (default: false) |
333
+ | `allowEdit` | `boolean` | Optional | Open in edit mode with full editing capabilities (default: **true**) |
323
334
 
324
335
  #### 💾 `downloadWorkbook()`
325
336
  Trigger browser download of the workbook.
@@ -328,17 +339,23 @@ Trigger browser download of the workbook.
328
339
  function downloadWorkbook(file: Blob, filename: string): void
329
340
  ```
330
341
 
331
- #### 🔗 `getExcelForWebWorkbookUrl()`
342
+ #### 🔗 `getExcelForWebWorkbookUrl()`
332
343
  Get the Excel for Web URL without opening (useful for custom integrations).
333
344
 
334
345
  ```typescript
335
346
  async function getExcelForWebWorkbookUrl(
336
- file: Blob,
337
- filename?: string,
338
- allowTyping?: boolean
347
+ file: Blob,
348
+ filename?: string,
349
+ allowEdit?: boolean
339
350
  ): Promise<string>
340
351
  ```
341
352
 
353
+ | Parameter | Type | Required | Description |
354
+ |-----------|------|----------|-------------|
355
+ | `file` | `Blob` | ✅ **Required** | Generated workbook |
356
+ | `filename` | `string` | Optional | Custom filename |
357
+ | `allowEdit` | `boolean` | Optional | Use edit URL with full editing capabilities (default: **true**) |
358
+
342
359
  ---
343
360
 
344
361
  ## 🔧 Type Definitions
@@ -190,8 +190,8 @@ exports.headers = {
190
190
  };
191
191
  exports.OFU = {
192
192
  ViewUrl: "https://view.officeapps.live.com/op/view.aspx?src=http://connectedWorkbooks.excel/",
193
+ editUrl: "https://view.officeapps.live.com/op/edit.aspx?app=x&src=http://connectedWorkbooks.excel/",
193
194
  PostUrl: "https://view.officeapps.live.com/op/viewpost.aspx?src=http://connectedWorkbooks.excel/",
194
- AllowTyping: "AllowTyping",
195
195
  WdOrigin: "wdOrigin",
196
196
  OpenInExcelOririgin: "OpenInExcel",
197
197
  };
@@ -3,5 +3,5 @@ export declare const generateSingleQueryWorkbook: (query: QueryInfo, initialData
3
3
  export declare const generateTableWorkbookFromHtml: (htmlTable: HTMLTableElement, fileConfigs?: FileConfigs) => Promise<Blob>;
4
4
  export declare const generateTableWorkbookFromGrid: (grid: Grid, fileConfigs?: FileConfigs) => Promise<Blob>;
5
5
  export declare const downloadWorkbook: (file: Blob, filename: string) => void;
6
- export declare const openInExcelWeb: (file: Blob, filename?: string, allowTyping?: boolean) => Promise<void>;
7
- export declare const getExcelForWebWorkbookUrl: (file: Blob, filename?: string, allowTyping?: boolean) => Promise<string>;
6
+ export declare const openInExcelWeb: (file: Blob, filename?: string, allowEdit?: boolean) => Promise<void>;
7
+ export declare const getExcelForWebWorkbookUrl: (file: Blob, filename?: string, allowEdit?: boolean) => Promise<string>;
@@ -166,62 +166,68 @@ var downloadWorkbook = function (file, filename) {
166
166
  }
167
167
  };
168
168
  exports.downloadWorkbook = downloadWorkbook;
169
- var openInExcelWeb = function (file, filename, allowTyping) { return __awaiter(void 0, void 0, void 0, function () {
170
- var url, error_1;
171
- return __generator(this, function (_a) {
172
- switch (_a.label) {
173
- case 0:
174
- _a.trys.push([0, 2, , 3]);
175
- return [4 /*yield*/, (0, exports.getExcelForWebWorkbookUrl)(file, filename, allowTyping)];
176
- case 1:
177
- url = _a.sent();
178
- window.open(url, "_blank");
179
- return [3 /*break*/, 3];
180
- case 2:
181
- error_1 = _a.sent();
182
- console.error("An error occurred:", error_1);
183
- return [3 /*break*/, 3];
184
- case 3: return [2 /*return*/];
185
- }
169
+ var openInExcelWeb = function (file, filename, allowEdit) {
170
+ if (allowEdit === void 0) { allowEdit = true; }
171
+ return __awaiter(void 0, void 0, void 0, function () {
172
+ var url, error_1;
173
+ return __generator(this, function (_a) {
174
+ switch (_a.label) {
175
+ case 0:
176
+ _a.trys.push([0, 2, , 3]);
177
+ return [4 /*yield*/, (0, exports.getExcelForWebWorkbookUrl)(file, filename, allowEdit)];
178
+ case 1:
179
+ url = _a.sent();
180
+ window.open(url, "_blank");
181
+ return [3 /*break*/, 3];
182
+ case 2:
183
+ error_1 = _a.sent();
184
+ console.error("An error occurred:", error_1);
185
+ return [3 /*break*/, 3];
186
+ case 3: return [2 /*return*/];
187
+ }
188
+ });
186
189
  });
187
- }); };
190
+ };
188
191
  exports.openInExcelWeb = openInExcelWeb;
189
- var getExcelForWebWorkbookUrl = function (file, filename, allowTyping) { return __awaiter(void 0, void 0, void 0, function () {
190
- var fileContent, fileNameGuid, allowTypingParam, response, error_2;
191
- return __generator(this, function (_a) {
192
- switch (_a.label) {
193
- case 0:
194
- // Check if the file exists
195
- if (file.size <= 0) {
196
- throw new Error("File is empty");
197
- }
198
- fileContent = file;
199
- fileNameGuid = new Date().getTime().toString() + (filename ? "_" + filename : "") + ".xlsx";
200
- allowTypingParam = allowTyping ? 1 : 0;
201
- _a.label = 1;
202
- case 1:
203
- _a.trys.push([1, 3, , 4]);
204
- return [4 /*yield*/, fetch("".concat(constants_1.OFU.PostUrl).concat(fileNameGuid, "&").concat(constants_1.OFU.WdOrigin, "=").concat(constants_1.OFU.OpenInExcelOririgin), {
205
- method: "POST",
206
- headers: constants_1.headers,
207
- body: fileContent,
208
- })];
209
- case 2:
210
- response = _a.sent();
211
- // Check if the response is successful
212
- if (response.ok) {
213
- // if upload was successful - open the file in a new tab
214
- return [2 /*return*/, "".concat(constants_1.OFU.ViewUrl).concat(fileNameGuid, "&").concat(constants_1.OFU.AllowTyping, "=").concat(allowTypingParam, "&").concat(constants_1.OFU.WdOrigin, "=").concat(constants_1.OFU.OpenInExcelOririgin)];
215
- }
216
- else {
217
- throw new Error("File upload failed. Status code: ".concat(response.status));
218
- }
219
- return [3 /*break*/, 4];
220
- case 3:
221
- error_2 = _a.sent();
222
- throw new Error("An error occurred: ".concat(error_2));
223
- case 4: return [2 /*return*/];
224
- }
192
+ var getExcelForWebWorkbookUrl = function (file, filename, allowEdit) {
193
+ if (allowEdit === void 0) { allowEdit = true; }
194
+ return __awaiter(void 0, void 0, void 0, function () {
195
+ var fileContent, fileNameGuid, baseUrl, response, error_2;
196
+ return __generator(this, function (_a) {
197
+ switch (_a.label) {
198
+ case 0:
199
+ // Check if the file exists
200
+ if (file.size <= 0) {
201
+ throw new Error("File is empty");
202
+ }
203
+ fileContent = file;
204
+ fileNameGuid = new Date().getTime().toString() + (filename ? "_" + filename : "") + ".xlsx";
205
+ baseUrl = allowEdit ? constants_1.OFU.editUrl : constants_1.OFU.ViewUrl;
206
+ _a.label = 1;
207
+ case 1:
208
+ _a.trys.push([1, 3, , 4]);
209
+ return [4 /*yield*/, fetch("".concat(constants_1.OFU.PostUrl).concat(fileNameGuid, "&").concat(constants_1.OFU.WdOrigin, "=").concat(constants_1.OFU.OpenInExcelOririgin), {
210
+ method: "POST",
211
+ headers: constants_1.headers,
212
+ body: fileContent,
213
+ })];
214
+ case 2:
215
+ response = _a.sent();
216
+ // Check if the response is successful
217
+ if (response.ok) {
218
+ // if upload was successful - return the URL
219
+ return [2 /*return*/, "".concat(baseUrl).concat(fileNameGuid, "&").concat(constants_1.OFU.WdOrigin, "=").concat(constants_1.OFU.OpenInExcelOririgin)];
220
+ }
221
+ else {
222
+ throw new Error("File upload failed. Status code: ".concat(response.status));
223
+ }
224
+ return [3 /*break*/, 4];
225
+ case 3:
226
+ error_2 = _a.sent();
227
+ throw new Error("An error occurred: ".concat(error_2));
228
+ case 4: return [2 /*return*/];
229
+ }
230
+ });
225
231
  });
226
- }); };
232
+ };
227
233
  exports.getExcelForWebWorkbookUrl = getExcelForWebWorkbookUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/connected-workbooks",
3
- "version": "3.4.1",
3
+ "version": "3.4.2",
4
4
  "description": "Microsoft backed, Excel advanced xlsx workbook generation JavaScript library",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -57,11 +57,11 @@
57
57
  "@types/jszip": "^3.4.1",
58
58
  "@types/uuid": "^9.0.2",
59
59
  "@types/webpack-bundle-analyzer": "^4.6.0",
60
- "@typescript-eslint/eslint-plugin": "^4.28.2",
61
- "@typescript-eslint/parser": "^4.28.2",
60
+ "@typescript-eslint/eslint-plugin": "^8.54.0",
61
+ "@typescript-eslint/parser": "^8.54.0",
62
62
  "@webpack-cli/generators": "^3.0.7",
63
63
  "babel-jest": "^27.0.6",
64
- "eslint": "^7.30.0",
64
+ "eslint": "^9.39.2",
65
65
  "eslint-config-prettier": "^8.3.0",
66
66
  "eslint-plugin-jest": "^24.3.6",
67
67
  "eslint-plugin-prettier": "^3.4.0",