@microsoft/connected-workbooks 3.1.1-beta.1 → 3.1.1-beta.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/dist/main.js +106 -187
- package/dist/utils/constants.js +5 -0
- package/dist/workbookManager.js +22 -16
- package/package.json +1 -2
package/dist/utils/constants.js
CHANGED
|
@@ -143,3 +143,8 @@ export var URLS = {
|
|
|
143
143
|
export var headers = {
|
|
144
144
|
"Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
145
145
|
};
|
|
146
|
+
export var OFU = {
|
|
147
|
+
ViewUrl: "https://view.officeapps.live.com/op/view.aspx?src=http://connectedWorkbooks.excel/",
|
|
148
|
+
PostUrl: "https://view.officeapps.live.com/op/viewpost.aspx?src=http://connectedWorkbooks.excel/",
|
|
149
|
+
allowTyping: "AllowTyping",
|
|
150
|
+
};
|
package/dist/workbookManager.js
CHANGED
|
@@ -36,11 +36,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
-
import axios from "axios";
|
|
40
39
|
import JSZip from "jszip";
|
|
41
40
|
import { pqUtils, xmlPartsUtils, htmlUtils, gridUtils } from "./utils";
|
|
42
41
|
import { SIMPLE_BLANK_TABLE_TEMPLATE, SIMPLE_QUERY_WORKBOOK_TEMPLATE } from "./workbookTemplate";
|
|
43
|
-
import { defaults, emptyQueryMashupErr, blobFileType, application, templateWithInitialDataErr, tableNotFoundErr, headers } from "./utils/constants";
|
|
42
|
+
import { defaults, emptyQueryMashupErr, blobFileType, application, templateWithInitialDataErr, tableNotFoundErr, headers, OFU } from "./utils/constants";
|
|
44
43
|
import { generateSingleQueryMashup } from "./generators";
|
|
45
44
|
export var generateSingleQueryWorkbook = function (query, initialDataGrid, fileConfigs) { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
45
|
var templateFile, zip, _a, tableData;
|
|
@@ -161,31 +160,38 @@ export var downloadWorkbook = function (file, filename) {
|
|
|
161
160
|
}
|
|
162
161
|
};
|
|
163
162
|
export var openInExcelWeb = function (file, filename, allowTyping) { return __awaiter(void 0, void 0, void 0, function () {
|
|
164
|
-
var fileContent,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
switch (_b.label) {
|
|
163
|
+
var fileContent, fileNameGuid, allowTypingParam, response, error_1;
|
|
164
|
+
return __generator(this, function (_a) {
|
|
165
|
+
switch (_a.label) {
|
|
168
166
|
case 0:
|
|
169
|
-
if (!(file.size > 0)) return [3 /*break*/,
|
|
167
|
+
if (!(file.size > 0)) return [3 /*break*/, 4];
|
|
170
168
|
fileContent = file;
|
|
171
|
-
|
|
172
|
-
fileNameGuid = (_a = new Date().getTime().toString() + "_" + filename) !== null && _a !== void 0 ? _a : "";
|
|
169
|
+
fileNameGuid = new Date().getTime().toString() + (filename ? "_" + filename : "") + ".xlsx";
|
|
173
170
|
allowTypingParam = allowTyping ? 1 : 0;
|
|
174
|
-
|
|
171
|
+
_a.label = 1;
|
|
172
|
+
case 1:
|
|
173
|
+
_a.trys.push([1, 3, , 4]);
|
|
174
|
+
return [4 /*yield*/, fetch("".concat(OFU.PostUrl).concat(fileNameGuid), {
|
|
175
|
+
method: "POST",
|
|
175
176
|
headers: headers,
|
|
177
|
+
body: fileContent,
|
|
176
178
|
})];
|
|
177
|
-
case
|
|
178
|
-
response =
|
|
179
|
+
case 2:
|
|
180
|
+
response = _a.sent();
|
|
179
181
|
// Check if the response is successful
|
|
180
|
-
if (response.
|
|
182
|
+
if (response.ok) {
|
|
181
183
|
// if upload was successful - open the file in a new tab
|
|
182
|
-
window.open("
|
|
184
|
+
window.open("".concat(OFU.ViewUrl).concat(fileNameGuid, "&").concat(OFU.allowTyping, "=").concat(allowTypingParam), "_blank");
|
|
183
185
|
}
|
|
184
186
|
else {
|
|
185
187
|
throw new Error("File upload failed. Status code: ".concat(response.status));
|
|
186
188
|
}
|
|
187
|
-
|
|
188
|
-
case
|
|
189
|
+
return [3 /*break*/, 4];
|
|
190
|
+
case 3:
|
|
191
|
+
error_1 = _a.sent();
|
|
192
|
+
console.error("An error occurred:", error_1);
|
|
193
|
+
return [3 /*break*/, 4];
|
|
194
|
+
case 4: return [2 /*return*/];
|
|
189
195
|
}
|
|
190
196
|
});
|
|
191
197
|
}); };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/connected-workbooks",
|
|
3
|
-
"version": "3.1.1-beta.
|
|
3
|
+
"version": "3.1.1-beta.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",
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/microsoft/connected-workbooks#readme",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"axios": "^1.6.8",
|
|
41
40
|
"base64-js": "^1.5.1",
|
|
42
41
|
"buffer": "^6.0.3",
|
|
43
42
|
"jszip": "^3.5.0",
|