@microsoft/connected-workbooks
Version:
Microsoft backed, Excel advanced xlsx workbook generation JavaScript library
213 lines (212 loc) • 11.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.customXML = exports.OFU = exports.headers = exports.URLS = exports.defaults = exports.elementAttributesValues = exports.dataTypeKind = exports.elementAttributes = exports.element = exports.Errors = exports.customXmlXmlPath = exports.contentTypesXmlPath = exports.docPropsAppXmlPath = exports.labelInfoXmlPath = exports.workbookRelsXmlPath = exports.docPropsRootElement = exports.docMetadataXmlPath = exports.relsXmlPath = exports.docPropsCoreXmlPath = exports.section1mPath = exports.pivotCachesPath = exports.tablesFolderPath = exports.queryTablesPath = exports.workbookXmlPath = exports.queryTableXmlPath = exports.tableXmlPath = exports.sheetsXmlPath = exports.sharedStringsXmlPath = exports.connectionsXmlPath = exports.maxCellCharacters = exports.BOM = exports.falseStr = exports.trueStr = exports.maxQueryLength = exports.divider = exports.section1PathPrefix = exports.emptyValue = exports.falseValue = exports.trueValue = exports.pivotCachesPathPrefix = exports.xmlTextResultType = exports.textResultType = exports.application = exports.uint8ArrayType = exports.blobFileType = void 0;
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
exports.blobFileType = "blob";
exports.uint8ArrayType = "uint8array";
exports.application = "application/xlsx";
exports.textResultType = "text";
exports.xmlTextResultType = "text/xml";
exports.pivotCachesPathPrefix = "pivotCacheDefinition";
exports.trueValue = "1";
exports.falseValue = "0";
exports.emptyValue = "";
exports.section1PathPrefix = "Section1/";
exports.divider = "/";
exports.maxQueryLength = 80;
exports.trueStr = "true";
exports.falseStr = "false";
exports.BOM = "\ufeff";
exports.maxCellCharacters = 32767;
exports.connectionsXmlPath = "xl/connections.xml";
exports.sharedStringsXmlPath = "xl/sharedStrings.xml";
exports.sheetsXmlPath = "xl/worksheets/sheet1.xml";
exports.tableXmlPath = "xl/tables/table1.xml";
exports.queryTableXmlPath = "xl/queryTables/queryTable1.xml";
exports.workbookXmlPath = "xl/workbook.xml";
exports.queryTablesPath = "xl/queryTables/";
exports.tablesFolderPath = "xl/tables/";
exports.pivotCachesPath = "xl/pivotCache/";
exports.section1mPath = "Formulas/Section1.m";
exports.docPropsCoreXmlPath = "docProps/core.xml";
exports.relsXmlPath = "_rels/.rels";
exports.docMetadataXmlPath = "docMetadata";
exports.docPropsRootElement = "cp:coreProperties";
exports.workbookRelsXmlPath = "xl/_rels/workbook.xml.rels";
exports.labelInfoXmlPath = "docMetadata/LabelInfo.xml";
exports.docPropsAppXmlPath = "docProps/app.xml";
exports.contentTypesXmlPath = "[Content_Types].xml";
exports.customXmlXmlPath = "customXml";
exports.Errors = {
sharedStringsNotFound: "SharedStrings were not found in template",
connectionsNotFound: "Connections were not found in template",
workbookNotFound: "workbook was not found in template",
sheetsNotFound: "Sheets were not found in template",
base64NotFound: "Base64 was not found in template",
emptyQueryMashup: "Query mashup is empty",
queryNameNotFound: "Query name was not found",
queryAndPivotTableNotFound: "No such query found in Query Table or Pivot Table found in given template",
queryConnectionNotFound: "No connection found for query",
formulaSectionNotFound: "Formula section wasn't found in template",
queryTableNotFound: "Query table wasn't found in template",
tableNotFound: "Table wasn't found in template",
tableReferenceNotFound: "Reference not found in the table XML.",
invalidValueInColumn: "Invalid cell value in column",
headerNotFound: "Invalid JSON file, header is missing",
invalidDataType: "Invalid JSON file, invalid data type",
queryNameMaxLength: "Query names are limited to 80 characters",
queryNameInvalidChars: 'Query names cannot contain periods or quotation marks. (. ")',
emptyQueryName: "Query name cannot be empty",
stylesNotFound: "Styles were not found in template",
invalidColumnName: "Invalid column name",
promotedHeadersCannotBeUsedWithoutAdjustingColumnNames: "Headers cannot be promoted without adjusting column names",
unexpected: "Unexpected error",
arrayIsntMxN: "Array isn't MxN",
relsNotFound: ".rels were not found in template",
xlRelsNotFound: "workbook.xml.rels were not found xl",
columnIndexOutOfRange: "Column index out of range",
relationship: "Relationship not found",
contentTypesNotFound: "contentTypes was not found in file",
contentTypesParse: "Failed to parse [Content_Types].xml: Invalid XML structure",
contentTypesElementNotFound: "contentTypes element was not found in parsed document",
workbookRelsParse: "Failed to parse workbook relationships XML: Invalid XML structure",
xmlParse: "Failed to parse XML: Parser error detected",
relsParse: "Failed to parse .rels XML",
connectionsParse: "Failed to parse connections XML",
sharedStringsParse: "Failed to parse shared strings XML",
worksheetParse: "Failed to parse worksheet XML",
queryTableParse: "Failed to parse query table XML",
pivotTableParse: "Failed to parse pivot table XML",
workbookParse: "Failed to parse workbook XML",
tableParse: "Failed to parse table XML",
tablePathParse: "Failed to parse table XML for",
invalidCellValueErr: "Cell content exceeds maximum length of " + exports.maxCellCharacters + " characters",
};
exports.element = {
sharedStringTable: "sst",
text: "t",
sharedStringItem: "si",
cellValue: "v",
databaseProperties: "dbPr",
queryTable: "queryTable",
cacheSource: "cacheSource",
item: "Item",
items: "Items",
itemPath: "ItemPath",
itemType: "ItemType",
itemLocation: "ItemLocation",
entry: "Entry",
stableEntries: "StableEntries",
tableColumns: "tableColumns",
tableColumn: "tableColumn",
table: "table",
autoFilter: "autoFilter",
definedName: "definedName",
queryTableFields: "queryTableFields",
queryTableField: "queryTableField",
queryTableRefresh: "queryTableRefresh",
sheetData: "sheetData",
row: "row",
dimension: "dimension",
selection: "selection",
kindCell: "c",
sheet: "sheet",
override: "Override",
relationship: "Relationship",
relationships: "Relationships",
};
exports.elementAttributes = {
connection: "connection",
command: "command",
refreshOnLoad: "refreshOnLoad",
count: "count",
uniqueCount: "uniqueCount",
queryTable: "queryTable",
connectionId: "connectionId",
cacheSource: "cacheSource",
name: "name",
description: "description",
id: "id",
Id: "Id",
relationId: "r:id",
relationId1: "RId1",
relationId2: "RId2",
relationId3: "RId3",
type: "Type",
value: "Value",
relationshipInfo: "RelationshipInfoContainer",
resultType: "ResultType",
fillColumnNames: "FillColumnNames",
fillTarget: "FillTarget",
fillLastUpdated: "FillLastUpdated",
day: "d",
uniqueName: "uniqueName",
queryTableFieldId: "queryTableFieldId",
reference: "ref",
sqref: "sqref",
tableColumnId: "tableColumnId",
nextId: "nextId",
row: "r",
spans: "spans",
x14acDyDescent: "x14ac:dyDescent",
xr3uid: "xr3:uid",
space: "xml:space",
target: "Target",
partName: "PartName",
contentType: "ContentType",
relationshipIdPrefix: "rId",
};
exports.dataTypeKind = {
string: "str",
number: "1",
boolean: "b",
};
exports.elementAttributesValues = {
connectionName: function (queryName) { return "Query - ".concat(queryName); },
connectionDescription: function (queryName) { return "Connection to the '".concat(queryName, "' query in the workbook."); },
connection: function (queryName) { return "Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=\"".concat(queryName, "\";"); },
connectionCommand: function (queryName) { return "SELECT * FROM [".concat(queryName.replace(/]/g, ']]'), "]"); },
tableResultType: function () { return "sTable"; },
};
exports.defaults = {
queryName: "Query1",
sheetName: "Sheet1",
columnName: "Column",
tableName: "Table1",
};
exports.URLS = {
PQ: [
"http://schemas.microsoft.com/DataMashup",
"http://schemas.microsoft.com/DataExplorer",
"http://schemas.microsoft.com/DataMashup/Temp",
"http://schemas.microsoft.com/DataExplorer/Temp",
],
CONNECTED_WORKBOOK: "http://schemas.microsoft.com/ConnectedWorkbook",
};
// Content-Type header to indicate that the content is an Excel document
exports.headers = {
"Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
};
exports.OFU = {
ViewUrl: "https://view.officeapps.live.com/op/view.aspx?src=http://connectedWorkbooks.excel/",
editUrl: "https://view.officeapps.live.com/op/edit.aspx?app=x&src=http://connectedWorkbooks.excel/",
PostUrl: "https://view.officeapps.live.com/op/viewpost.aspx?src=http://connectedWorkbooks.excel/",
WdOrigin: "wdOrigin",
OpenInExcelOririgin: "OpenInExcel",
};
exports.customXML = {
customXMLItemContent: "<?xml version=\"1.0\" encoding=\"utf-8\"?><ConnectedWorkbook xmlns=\"http://schemas.microsoft.com/ConnectedWorkbook\" version=\"1.0.0\"></ConnectedWorkbook>",
customXMLItemPropsContent: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<ds:datastoreItem ds:itemID=\"{0B384C3C-E1D4-401B-8CF4-6285949D7671}\" xmlns:ds=\"http://schemas.openxmlformats.org/officeDocument/2006/customXml\"><ds:schemaRefs><ds:schemaRef ds:uri=\"http://schemas.microsoft.com/ConnectedWorkbook\"/></ds:schemaRefs></ds:datastoreItem>",
connectedWorkbookTag: '<ConnectedWorkbook',
itemNumberPattern: /item(\d+)\.xml$/,
itemFilePattern: /^item\d+\.xml$/,
itemPropsPartNameTemplate: function (itemIndex) { return "/customXml/itemProps".concat(itemIndex, ".xml"); },
contentType: "application/vnd.openxmlformats-officedocument.customXmlProperties+xml",
itemPathTemplate: function (itemNumber) { return "customXml/item".concat(itemNumber, ".xml"); },
itemPropsPathTemplate: function (itemNumber) { return "customXml/itemProps".concat(itemNumber, ".xml"); },
itemRelsPathTemplate: function (itemNumber) { return "customXml/_rels/item".concat(itemNumber, ".xml.rels"); },
customXMLRelationships: function (itemNumber) { return "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\"><Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps\" Target=\"itemProps".concat(itemNumber, ".xml\"/></Relationships>"); },
relationshipType: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml",
relativeItemPathTemplate: function (itemNumber) { return "../customXml/item".concat(itemNumber, ".xml"); },
};