@trebco/treb 32.13.2 → 36.1.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/api-generator/api-generator-types.ts +3 -0
- package/api-generator/api-generator.ts +15 -1
- package/bun.lock +145 -99
- package/dist/chunk-43DLP2OX.mjs +11 -0
- package/dist/chunk-4CKS56PE.mjs +11 -0
- package/dist/chunk-75PARUQE.mjs +11 -0
- package/dist/chunk-7QD63AZS.mjs +24601 -0
- package/dist/chunk-A55ARVRD.mjs +11 -0
- package/dist/chunk-DESAKYW4.mjs +11 -0
- package/dist/chunk-EQ2R5W6P.mjs +24565 -0
- package/dist/chunk-IYJU2J6D.mjs +24601 -0
- package/dist/chunk-KSJFPGXT.mjs +11 -0
- package/dist/chunk-ORQFKLXM.mjs +24601 -0
- package/dist/chunk-SFDNNDHY.mjs +11 -0
- package/dist/chunk-T47DX5MI.mjs +11 -0
- package/dist/chunk-T6ILBVEX.mjs +11 -0
- package/dist/chunk-TPRCDYYG.mjs +11 -0
- package/dist/chunk-YAHNOOHO.mjs +11 -0
- package/dist/treb-export-worker.mjs +9 -2
- package/dist/treb-spreadsheet.mjs +7 -19
- package/dist/treb.d.ts +20 -4
- package/esbuild-composite.mjs +18 -6
- package/esbuild-utils.mjs +62 -3
- package/i18n/languages/treb-i18n-da.mjs +1 -1
- package/i18n/languages/treb-i18n-de.mjs +1 -1
- package/i18n/languages/treb-i18n-es.mjs +1 -1
- package/i18n/languages/treb-i18n-fr.mjs +1 -1
- package/i18n/languages/treb-i18n-it.mjs +1 -1
- package/i18n/languages/treb-i18n-nl.mjs +1 -1
- package/i18n/languages/treb-i18n-no.mjs +1 -1
- package/i18n/languages/treb-i18n-pl.mjs +1 -1
- package/i18n/languages/treb-i18n-pt.mjs +1 -1
- package/i18n/languages/treb-i18n-sv.mjs +1 -1
- package/ooxml-types/README.md +141 -0
- package/ooxml-types/package.json +5 -0
- package/ooxml-types/src/types/drawingml/chart.ts +327 -0
- package/ooxml-types/src/types/drawingml/index.ts +63 -0
- package/ooxml-types/src/types/drawingml/spreadsheetDrawing.ts +105 -0
- package/ooxml-types/src/types/drawingml/theme.ts +104 -0
- package/ooxml-types/src/types/index.ts +3 -0
- package/ooxml-types/src/types/package/contentTypes.ts +49 -0
- package/ooxml-types/src/types/package/docProps.ts +46 -0
- package/ooxml-types/src/types/package/index.ts +17 -0
- package/ooxml-types/src/types/package/relationships.ts +37 -0
- package/ooxml-types/src/types/spreadsheetml/columns.ts +20 -0
- package/ooxml-types/src/types/spreadsheetml/comments.ts +30 -0
- package/ooxml-types/src/types/spreadsheetml/dataFeatures.ts +261 -0
- package/ooxml-types/src/types/spreadsheetml/enums.ts +175 -0
- package/ooxml-types/src/types/spreadsheetml/index.ts +186 -0
- package/ooxml-types/src/types/spreadsheetml/metadata.ts +90 -0
- package/ooxml-types/src/types/spreadsheetml/misc.ts +35 -0
- package/ooxml-types/src/types/spreadsheetml/pageLayout.ts +83 -0
- package/ooxml-types/src/types/spreadsheetml/sharedStrings.ts +33 -0
- package/ooxml-types/src/types/spreadsheetml/sheetData.ts +70 -0
- package/ooxml-types/src/types/spreadsheetml/sheetProperties.ts +86 -0
- package/ooxml-types/src/types/spreadsheetml/sheetViews.ts +51 -0
- package/ooxml-types/src/types/spreadsheetml/sparkline.ts +46 -0
- package/ooxml-types/src/types/spreadsheetml/styles.ts +274 -0
- package/ooxml-types/src/types/spreadsheetml/table.ts +106 -0
- package/ooxml-types/src/types/spreadsheetml/util.ts +15 -0
- package/ooxml-types/src/types/spreadsheetml/workbook.ts +165 -0
- package/ooxml-types/src/types/spreadsheetml/worksheet.ts +60 -0
- package/package.json +13 -11
- package/treb-base-types/src/api_types.ts +1 -1
- package/treb-base-types/src/area-utils.ts +1 -1
- package/treb-base-types/src/area.ts +1 -1
- package/treb-base-types/src/basic_types.ts +1 -1
- package/treb-base-types/src/cell.ts +1 -1
- package/treb-base-types/src/cells.ts +1 -1
- package/treb-base-types/src/color.ts +1 -1
- package/treb-base-types/src/dom-utilities.ts +1 -1
- package/treb-base-types/src/evaluate-options.ts +1 -1
- package/treb-base-types/src/font-stack.ts +1 -1
- package/treb-base-types/src/gradient.ts +1 -1
- package/treb-base-types/src/import.ts +1 -1
- package/treb-base-types/src/index-standalone.ts +1 -1
- package/treb-base-types/src/index.ts +2 -1
- package/treb-base-types/src/layout.ts +1 -1
- package/treb-base-types/src/localization.ts +1 -1
- package/treb-base-types/src/rectangle.ts +1 -1
- package/treb-base-types/src/render_text.ts +7 -1
- package/treb-base-types/src/style.ts +1 -1
- package/treb-base-types/src/table.ts +1 -1
- package/treb-base-types/src/text_part.ts +1 -1
- package/treb-base-types/src/theme.ts +1 -1
- package/treb-base-types/src/union.ts +4 -1
- package/treb-base-types/src/value-type.ts +1 -1
- package/treb-base-types/src/worker-proxy.ts +294 -0
- package/treb-base-types/style/resizable.css +1 -1
- package/treb-calculator/src/calculator.ts +133 -14
- package/treb-calculator/src/complex-math.ts +1 -1
- package/treb-calculator/src/dag/array-vertex.ts +1 -1
- package/treb-calculator/src/dag/calculation_leaf_vertex.ts +1 -1
- package/treb-calculator/src/dag/graph.ts +1 -1
- package/treb-calculator/src/dag/spreadsheet_vertex.ts +1 -1
- package/treb-calculator/src/dag/spreadsheet_vertex_base.ts +1 -1
- package/treb-calculator/src/dag/state_leaf_vertex.ts +1 -1
- package/treb-calculator/src/dag/vertex.ts +1 -1
- package/treb-calculator/src/descriptors.ts +9 -1
- package/treb-calculator/src/expression-calculator.ts +1 -1
- package/treb-calculator/src/function-error.ts +1 -1
- package/treb-calculator/src/function-library.ts +1 -1
- package/treb-calculator/src/functions/base-functions.ts +10 -4
- package/treb-calculator/src/functions/beta.ts +1 -1
- package/treb-calculator/src/functions/checkbox.ts +1 -1
- package/treb-calculator/src/functions/complex-functions.ts +1 -1
- package/treb-calculator/src/functions/date-utils.ts +1 -1
- package/treb-calculator/src/functions/finance-functions.ts +2 -4
- package/treb-calculator/src/functions/fp.ts +1 -1
- package/treb-calculator/src/functions/function-utilities.ts +1 -1
- package/treb-calculator/src/functions/gamma.ts +1 -1
- package/treb-calculator/src/functions/information-functions.ts +1 -1
- package/treb-calculator/src/functions/lambda-functions.ts +4 -1
- package/treb-calculator/src/functions/matrix-functions.ts +1 -1
- package/treb-calculator/src/functions/normal.ts +1 -1
- package/treb-calculator/src/functions/regex-functions.ts +13 -4
- package/treb-calculator/src/functions/sparkline.ts +1 -1
- package/treb-calculator/src/functions/statistics-functions.ts +1 -1
- package/treb-calculator/src/functions/students-t.ts +1 -1
- package/treb-calculator/src/functions/text-functions.ts +5 -1
- package/treb-calculator/src/index.ts +1 -1
- package/treb-calculator/src/notifier-types.ts +1 -1
- package/treb-calculator/src/primitives.ts +1 -1
- package/treb-calculator/src/utilities.ts +1 -1
- package/treb-charts/src/chart-functions.ts +1 -1
- package/treb-charts/src/chart-types.ts +1 -1
- package/treb-charts/src/chart-utils.ts +1 -1
- package/treb-charts/src/chart.ts +1 -1
- package/treb-charts/src/default-chart-renderer.ts +1 -1
- package/treb-charts/src/index.ts +1 -1
- package/treb-charts/src/main.ts +1 -1
- package/treb-charts/src/quicksort.ts +1 -1
- package/treb-charts/src/rectangle.ts +1 -1
- package/treb-charts/src/renderer-type.ts +1 -1
- package/treb-charts/src/renderer.ts +1 -1
- package/treb-charts/src/util.ts +1 -1
- package/treb-charts/style/charts.scss +1 -1
- package/treb-data-model/src/annotation.ts +1 -1
- package/treb-data-model/src/conditional_format.ts +1 -1
- package/treb-data-model/src/data-validation.ts +1 -1
- package/treb-data-model/src/data_model.ts +32 -5
- package/treb-data-model/src/index.ts +1 -1
- package/treb-data-model/src/language-model.ts +1 -1
- package/treb-data-model/src/named.ts +1 -1
- package/treb-data-model/src/serialize_options.ts +1 -1
- package/treb-data-model/src/sheet.ts +1 -1
- package/treb-data-model/src/sheet_collection.ts +1 -1
- package/treb-data-model/src/sheet_selection.ts +1 -1
- package/treb-data-model/src/sheet_types.ts +1 -1
- package/treb-data-model/src/types.ts +1 -1
- package/treb-embed/src/content-types.d.ts +1 -1
- package/treb-embed/src/custom-element/global.d.ts +1 -1
- package/treb-embed/src/custom-element/spreadsheet-constructor.ts +1 -1
- package/treb-embed/src/custom-element/treb-global.ts +1 -1
- package/treb-embed/src/custom-element/treb-spreadsheet-element.ts +1 -1
- package/treb-embed/src/embedded-spreadsheet.ts +342 -149
- package/treb-embed/src/index.ts +1 -1
- package/treb-embed/src/options.ts +4 -2
- package/treb-embed/src/plugin.ts +1 -1
- package/treb-embed/src/progress-dialog.ts +1 -1
- package/treb-embed/src/selection-state.ts +1 -1
- package/treb-embed/src/spinner.ts +1 -1
- package/treb-embed/src/toolbar-message.ts +6 -1
- package/treb-embed/src/types.ts +13 -1
- package/treb-embed/style/autocomplete.scss +1 -1
- package/treb-embed/style/dark-theme.scss +1 -1
- package/treb-embed/style/defaults.scss +1 -1
- package/treb-embed/style/dialog.scss +1 -1
- package/treb-embed/style/dropdown-select.scss +1 -1
- package/treb-embed/style/font-stacks.scss +1 -1
- package/treb-embed/style/formula-bar.scss +1 -1
- package/treb-embed/style/grid.scss +1 -1
- package/treb-embed/style/layout.scss +1 -1
- package/treb-embed/style/mouse-mask.scss +1 -1
- package/treb-embed/style/note.scss +1 -1
- package/treb-embed/style/overlay-editor.scss +1 -1
- package/treb-embed/style/spinner.scss +1 -1
- package/treb-embed/style/tab-bar.scss +1 -1
- package/treb-embed/style/table.scss +1 -1
- package/treb-embed/style/theme-defaults.scss +1 -1
- package/treb-embed/style/toolbar.scss +1 -1
- package/treb-embed/style/tooltip.scss +1 -1
- package/treb-embed/style/treb-icons.scss +1 -1
- package/treb-embed/style/treb-spreadsheet-element.scss +1 -1
- package/treb-embed/style/z-index.scss +1 -1
- package/treb-export/src/address-type.ts +1 -1
- package/treb-export/src/base-template.ts +1 -1
- package/treb-export/src/column-width.ts +1 -1
- package/treb-export/src/drawing/bubble-chart-template.ts +1 -1
- package/treb-export/src/drawing/chart-template-components2.ts +1 -1
- package/treb-export/src/drawing/chart.ts +1 -1
- package/treb-export/src/drawing/column-chart-template2.ts +1 -1
- package/treb-export/src/drawing/donut-chart-template2.ts +1 -1
- package/treb-export/src/drawing/drawing.ts +1 -1
- package/treb-export/src/drawing/embedded-image.ts +1 -1
- package/treb-export/src/drawing/scatter-chart-template2.ts +1 -1
- package/treb-export/src/export.ts +121 -8
- package/treb-export/src/import-export-messages.ts +61 -0
- package/treb-export/src/import.ts +318 -301
- package/treb-export/src/index.worker.ts +85 -53
- package/treb-export/src/metadata.ts +71 -3
- package/treb-export/src/ooxml.ts +47 -0
- package/treb-export/src/relationship.ts +1 -1
- package/treb-export/src/shared-strings.ts +19 -15
- package/treb-export/src/template-2.ts +1 -1
- package/treb-export/src/unescape_xml.ts +1 -1
- package/treb-export/src/workbook-sheet.ts +11 -6
- package/treb-export/src/workbook-style.ts +137 -25
- package/treb-export/src/workbook-theme.ts +20 -4
- package/treb-export/src/workbook.ts +85 -88
- package/treb-export/src/xml-test.ts +1 -1
- package/treb-export/src/xml-utils.ts +1 -1
- package/treb-export/src/zip-wrapper.ts +1 -1
- package/treb-export/tsconfig.json +2 -1
- package/treb-format/src/format.test.ts +1 -1
- package/treb-format/src/format.ts +12 -5
- package/treb-format/src/format_cache.ts +3 -3
- package/treb-format/src/format_parser.ts +1 -1
- package/treb-format/src/index.ts +1 -1
- package/treb-format/src/number_format_section.ts +1 -1
- package/treb-format/src/value_parser.ts +1 -1
- package/treb-grid/src/editors/autocomplete.ts +1 -1
- package/treb-grid/src/editors/autocomplete_matcher.ts +1 -1
- package/treb-grid/src/editors/editor.ts +15 -6
- package/treb-grid/src/editors/external_editor.ts +33 -8
- package/treb-grid/src/editors/formula_bar.ts +12 -1
- package/treb-grid/src/editors/overlay_editor.ts +4 -1
- package/treb-grid/src/index.ts +1 -1
- package/treb-grid/src/layout/base_layout.ts +1 -1
- package/treb-grid/src/layout/grid_layout.ts +1 -1
- package/treb-grid/src/layout/mock-layout.ts +1 -1
- package/treb-grid/src/render/selection-renderer.ts +1 -1
- package/treb-grid/src/render/svg_header_overlay.ts +1 -1
- package/treb-grid/src/render/svg_selection_block.ts +1 -1
- package/treb-grid/src/render/tile_renderer.ts +36 -7
- package/treb-grid/src/types/border_constants.ts +1 -1
- package/treb-grid/src/types/clipboard_data.ts +1 -1
- package/treb-grid/src/types/clipboard_data2.ts +1 -1
- package/treb-grid/src/types/drag_mask.ts +1 -1
- package/treb-grid/src/types/external_editor_config.ts +1 -1
- package/treb-grid/src/types/grid.ts +181 -40
- package/treb-grid/src/types/grid_base.ts +7 -4
- package/treb-grid/src/types/grid_command.ts +7 -1
- package/treb-grid/src/types/grid_events.ts +2 -1
- package/treb-grid/src/types/grid_options.ts +1 -1
- package/treb-grid/src/types/scale-control.ts +1 -1
- package/treb-grid/src/types/set_range_options.ts +1 -1
- package/treb-grid/src/types/tab_bar.ts +1 -1
- package/treb-grid/src/types/tile.ts +1 -1
- package/treb-grid/src/types/update_flags.ts +1 -1
- package/treb-grid/src/util/fontmetrics.ts +1 -1
- package/treb-grid/src/util/ua.ts +1 -1
- package/treb-parser/src/csv-parser.ts +1 -1
- package/treb-parser/src/index.ts +1 -1
- package/treb-parser/src/md-parser.ts +1 -1
- package/treb-parser/src/parser-types.ts +1 -1
- package/treb-parser/src/parser.ts +1 -1
- package/treb-utils/src/event_source.ts +1 -1
- package/treb-utils/src/ievent_source.ts +1 -1
- package/treb-utils/src/index.ts +1 -1
- package/treb-utils/src/measurement.ts +1 -1
- package/treb-utils/src/scale.ts +1 -1
- package/treb-utils/src/serialize_html.ts +1 -1
- package/treb-utils/src/validate_uri.ts +1 -1
- package/tsproject.json +2 -3
- package/treb-embed/src/export-worker.ts +0 -44
|
@@ -14,18 +14,22 @@
|
|
|
14
14
|
* You should have received a copy of the GNU General Public License along
|
|
15
15
|
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
16
|
*
|
|
17
|
-
* Copyright 2022-
|
|
17
|
+
* Copyright 2022-2026 trebco, llc.
|
|
18
18
|
* info@treb.app
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
+
import * as OOXML from 'ooxml-types';
|
|
23
|
+
import { MapTags } from './ooxml';
|
|
24
|
+
|
|
25
|
+
|
|
22
26
|
// import * as ElementTree from 'elementtree';
|
|
23
27
|
// import { Element, ElementTree as Tree } from 'elementtree';
|
|
24
28
|
|
|
25
29
|
import { type CompositeBorderEdge, Style, type CellStyle, type PropertyKeys, type Color, IsHTMLColor, IsThemeColor, type ThemeColor, type HTMLColor, ThemeColorIndex } from 'treb-base-types';
|
|
26
30
|
import { Theme } from './workbook-theme';
|
|
27
31
|
import { NumberFormatCache } from 'treb-format';
|
|
28
|
-
import { XMLUtils } from './xml-utils';
|
|
32
|
+
// import { XMLUtils } from './xml-utils';
|
|
29
33
|
|
|
30
34
|
import { Unescape } from './unescape_xml';
|
|
31
35
|
|
|
@@ -1115,14 +1119,20 @@ export class StyleCache {
|
|
|
1115
1119
|
|
|
1116
1120
|
}
|
|
1117
1121
|
|
|
1118
|
-
public FromXML(
|
|
1122
|
+
public FromXML(stylesheet: OOXML.StyleSheet, theme: Theme): void {
|
|
1119
1123
|
|
|
1120
|
-
const FindAll = XMLUtils.FindAll.bind(XMLUtils, xml);
|
|
1124
|
+
// const FindAll = XMLUtils.FindAll.bind(XMLUtils, xml);
|
|
1121
1125
|
|
|
1122
1126
|
this.theme = theme;
|
|
1123
1127
|
|
|
1124
1128
|
// ---
|
|
1125
1129
|
|
|
1130
|
+
this.number_formats = MapTags(stylesheet.numFmts?.numFmt, element => ({
|
|
1131
|
+
id: element.$attributes?.numFmtId,
|
|
1132
|
+
format: Unescape(element.$attributes?.formatCode || ''),
|
|
1133
|
+
}));
|
|
1134
|
+
|
|
1135
|
+
/*
|
|
1126
1136
|
let composite = FindAll('styleSheet/numFmts/numFmt');
|
|
1127
1137
|
|
|
1128
1138
|
this.number_formats = composite.map(element => ({
|
|
@@ -1131,42 +1141,48 @@ export class StyleCache {
|
|
|
1131
1141
|
}));
|
|
1132
1142
|
|
|
1133
1143
|
// ---
|
|
1144
|
+
*/
|
|
1134
1145
|
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
if (typeof element.color.a$?.indexed !== 'undefined') {
|
|
1143
|
-
edge.color = Number(element.color.a$.indexed);
|
|
1144
|
-
}
|
|
1145
|
-
if (typeof element.color.a$?.theme !== 'undefined') {
|
|
1146
|
-
edge.theme = Number(element.color.a$.theme);
|
|
1147
|
-
}
|
|
1148
|
-
if (typeof element.color.a$?.tint !== 'undefined') {
|
|
1149
|
-
edge.tint = Number(element.color.a$.tint);
|
|
1150
|
-
}
|
|
1146
|
+
const ElementToBorderEdge = (element: OOXML.BorderEdge|undefined, edge: BorderEdge) => {
|
|
1147
|
+
if (element?.$attributes) {
|
|
1148
|
+
edge.style = element.$attributes.style;
|
|
1149
|
+
if (element.color) {
|
|
1150
|
+
edge.color = element.color.$attributes?.indexed;
|
|
1151
|
+
edge.theme = element.color.$attributes?.theme;
|
|
1152
|
+
edge.tint = element.color.$attributes?.tint;
|
|
1151
1153
|
}
|
|
1152
1154
|
}
|
|
1153
|
-
|
|
1154
1155
|
};
|
|
1155
|
-
|
|
1156
1156
|
|
|
1157
|
-
this.borders =
|
|
1157
|
+
this.borders = MapTags(stylesheet.borders?.border, element => {
|
|
1158
1158
|
const border: BorderStyle = JSON.parse(JSON.stringify(default_border));
|
|
1159
|
-
|
|
1160
1159
|
ElementToBorderEdge(element.left, border.left);
|
|
1161
1160
|
ElementToBorderEdge(element.right, border.right);
|
|
1162
1161
|
ElementToBorderEdge(element.top, border.top);
|
|
1163
1162
|
ElementToBorderEdge(element.bottom, border.bottom);
|
|
1164
|
-
|
|
1165
1163
|
return border;
|
|
1166
1164
|
});
|
|
1167
1165
|
|
|
1168
1166
|
// ---
|
|
1169
1167
|
|
|
1168
|
+
this.cell_xfs = MapTags(stylesheet.cellXfs?.xf, element => {
|
|
1169
|
+
const xf: CellXf = {
|
|
1170
|
+
number_format: element.$attributes?.numFmtId ?? -1,
|
|
1171
|
+
font: element.$attributes?.fontId ?? -1,
|
|
1172
|
+
fill: element.$attributes?.fillId ?? -1,
|
|
1173
|
+
border: element.$attributes?.borderId ?? -1,
|
|
1174
|
+
xfid: element.$attributes?.xfId ?? -1,
|
|
1175
|
+
};
|
|
1176
|
+
if (element.alignment) {
|
|
1177
|
+
xf.horizontal_alignment = element.alignment.$attributes?.horizontal;
|
|
1178
|
+
xf.vertical_alignment = element.alignment.$attributes?.vertical;
|
|
1179
|
+
xf.wrap_text = !!element.alignment.$attributes?.wrapText;
|
|
1180
|
+
xf.indent = element.alignment.$attributes?.indent;
|
|
1181
|
+
}
|
|
1182
|
+
return xf;
|
|
1183
|
+
});
|
|
1184
|
+
|
|
1185
|
+
/*
|
|
1170
1186
|
composite = FindAll('styleSheet/cellXfs/xf');
|
|
1171
1187
|
this.cell_xfs = composite.map(element => {
|
|
1172
1188
|
|
|
@@ -1188,9 +1204,46 @@ export class StyleCache {
|
|
|
1188
1204
|
return xf;
|
|
1189
1205
|
|
|
1190
1206
|
});
|
|
1207
|
+
*/
|
|
1191
1208
|
|
|
1192
1209
|
// ---
|
|
1193
1210
|
|
|
1211
|
+
this.fills = MapTags(stylesheet.fills?.fill, element => {
|
|
1212
|
+
const fill: Fill = { pattern_type: 'none' };
|
|
1213
|
+
if (element.patternFill) {
|
|
1214
|
+
const type = element.patternFill.$attributes?.patternType;
|
|
1215
|
+
switch(type) {
|
|
1216
|
+
case 'none':
|
|
1217
|
+
case undefined:
|
|
1218
|
+
break;
|
|
1219
|
+
|
|
1220
|
+
case 'solid':
|
|
1221
|
+
fill.pattern_type = 'solid';
|
|
1222
|
+
if (element.patternFill.fgColor) {
|
|
1223
|
+
fill.fg_color = {
|
|
1224
|
+
theme: element.patternFill.fgColor.$attributes?.theme,
|
|
1225
|
+
indexed: element.patternFill.fgColor.$attributes?.indexed,
|
|
1226
|
+
tint: element.patternFill.fgColor.$attributes?.tint,
|
|
1227
|
+
argb: element.patternFill.fgColor.$attributes?.rgb,
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
break;
|
|
1231
|
+
|
|
1232
|
+
default:
|
|
1233
|
+
{
|
|
1234
|
+
const match = type?.match(/^gray(\d+)$/);
|
|
1235
|
+
if (match) {
|
|
1236
|
+
fill.pattern_type = 'gray';
|
|
1237
|
+
fill.pattern_gray = Number(match[1]);
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
break;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
return fill;
|
|
1244
|
+
});
|
|
1245
|
+
|
|
1246
|
+
/*
|
|
1194
1247
|
const ParseFill = (element: any) => {
|
|
1195
1248
|
|
|
1196
1249
|
const fill: Fill = { pattern_type: 'none' };
|
|
@@ -1233,9 +1286,31 @@ export class StyleCache {
|
|
|
1233
1286
|
composite = FindAll('styleSheet/fills/fill');
|
|
1234
1287
|
|
|
1235
1288
|
this.fills = composite.map(ParseFill);
|
|
1289
|
+
*/
|
|
1236
1290
|
|
|
1237
1291
|
// ---
|
|
1238
1292
|
|
|
1293
|
+
this.fonts = MapTags(stylesheet.fonts?.font, element => {
|
|
1294
|
+
const font: Font = {};
|
|
1295
|
+
|
|
1296
|
+
font.italic = !!element.i;
|
|
1297
|
+
font.bold = !!element.b;
|
|
1298
|
+
font.underline = !!element.u;
|
|
1299
|
+
font.strike = !!element.strike;
|
|
1300
|
+
|
|
1301
|
+
font.size = element.sz?.$attributes?.val;
|
|
1302
|
+
font.scheme = element.scheme?.$attributes?.val;
|
|
1303
|
+
font.name = element.name?.$attributes?.val;
|
|
1304
|
+
font.family = element.family?.$attributes?.val;
|
|
1305
|
+
|
|
1306
|
+
font.color_theme = element.color?.$attributes?.theme;
|
|
1307
|
+
font.color_tint = element.color?.$attributes?.tint;
|
|
1308
|
+
font.color_argb = element.color?.$attributes?.rgb;
|
|
1309
|
+
|
|
1310
|
+
return font;
|
|
1311
|
+
});
|
|
1312
|
+
|
|
1313
|
+
/*
|
|
1239
1314
|
const ParseFont = (element: any) => {
|
|
1240
1315
|
|
|
1241
1316
|
const font: Font = {};
|
|
@@ -1277,7 +1352,43 @@ export class StyleCache {
|
|
|
1277
1352
|
|
|
1278
1353
|
composite = FindAll('styleSheet/fonts/font');
|
|
1279
1354
|
this.fonts = composite.map(ParseFont);
|
|
1355
|
+
*/
|
|
1280
1356
|
|
|
1357
|
+
// ---
|
|
1358
|
+
|
|
1359
|
+
const ParseDXFColor = (element: OOXML.Color): Color => {
|
|
1360
|
+
const color: Color = {};
|
|
1361
|
+
if (element.$attributes?.rgb) {
|
|
1362
|
+
(color as HTMLColor).text = '#' + element.$attributes.rgb.substring(2);
|
|
1363
|
+
}
|
|
1364
|
+
else if (element.$attributes?.theme !== undefined) {
|
|
1365
|
+
(color as ThemeColor).theme = element.$attributes.theme;
|
|
1366
|
+
if (element.$attributes.tint !== undefined) {
|
|
1367
|
+
(color as ThemeColor).tint = Math.round(element.$attributes.tint * 1000) / 1000;
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
return color;
|
|
1371
|
+
};
|
|
1372
|
+
|
|
1373
|
+
this.dxf_styles = MapTags(stylesheet.dxfs?.dxf, dxf => {
|
|
1374
|
+
const style: CellStyle = {};
|
|
1375
|
+
|
|
1376
|
+
if (dxf.font) {
|
|
1377
|
+
style.bold = !!dxf.font?.b;
|
|
1378
|
+
style.italic = !!dxf.font?.i;
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
if (dxf.font?.color?.$attributes) {
|
|
1382
|
+
style.text = ParseDXFColor(dxf.font.color);
|
|
1383
|
+
}
|
|
1384
|
+
if (dxf.fill?.patternFill?.bgColor?.$attributes) {
|
|
1385
|
+
style.fill = ParseDXFColor(dxf.fill.patternFill.bgColor);
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
return style;
|
|
1389
|
+
});
|
|
1390
|
+
|
|
1391
|
+
/*
|
|
1281
1392
|
// dxfs (differential formats) are inline. because reasons? not sure
|
|
1282
1393
|
// what's allowed in there, atm we're just looking at font color and
|
|
1283
1394
|
// background color.
|
|
@@ -1319,6 +1430,7 @@ export class StyleCache {
|
|
|
1319
1430
|
|
|
1320
1431
|
return style;
|
|
1321
1432
|
});
|
|
1433
|
+
*/
|
|
1322
1434
|
|
|
1323
1435
|
// console.info({dxfs: this.dxf_styles});
|
|
1324
1436
|
|
|
@@ -14,11 +14,13 @@
|
|
|
14
14
|
* You should have received a copy of the GNU General Public License along
|
|
15
15
|
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
16
|
*
|
|
17
|
-
* Copyright 2022-
|
|
17
|
+
* Copyright 2022-2026 trebco, llc.
|
|
18
18
|
* info@treb.app
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
+
import * as OOXML from 'ooxml-types';
|
|
23
|
+
|
|
22
24
|
export interface ColorSchemeElement {
|
|
23
25
|
name?: string;
|
|
24
26
|
value?: string;
|
|
@@ -27,8 +29,7 @@ export interface ColorSchemeElement {
|
|
|
27
29
|
|
|
28
30
|
export class Theme {
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
public static color_map = [
|
|
32
|
+
public static color_map: (keyof Omit<OOXML.ColorScheme, '$attributes'>)[] = [
|
|
32
33
|
'lt1', // bg 1
|
|
33
34
|
'dk1', // text 1
|
|
34
35
|
'lt2', // bg 2
|
|
@@ -47,8 +48,22 @@ export class Theme {
|
|
|
47
48
|
|
|
48
49
|
// private dom?: ElementTree.ElementTree;
|
|
49
50
|
|
|
50
|
-
public FromXML(
|
|
51
|
+
public FromXML(theme: OOXML.Theme): void {
|
|
52
|
+
|
|
53
|
+
const color_scheme = theme.themeElements.clrScheme;
|
|
54
|
+
for (const name of Theme.color_map) {
|
|
55
|
+
const element = color_scheme[name];
|
|
56
|
+
if (element.srgbClr) {
|
|
57
|
+
this.colors[name] = {name, value: element.srgbClr.$attributes?.val || '', type: 'rgb'};
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
else if (element.sysClr) {
|
|
61
|
+
this.colors[name] = {name, value: element.sysClr.$attributes?.lastClr || '', type: 'system'};
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
}
|
|
51
65
|
|
|
66
|
+
/*
|
|
52
67
|
const tag = Object.keys(xml)[0];
|
|
53
68
|
|
|
54
69
|
let namespace = '';
|
|
@@ -80,6 +95,7 @@ export class Theme {
|
|
|
80
95
|
|
|
81
96
|
}
|
|
82
97
|
}
|
|
98
|
+
*/
|
|
83
99
|
|
|
84
100
|
}
|
|
85
101
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* You should have received a copy of the GNU General Public License along
|
|
15
15
|
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
16
|
*
|
|
17
|
-
* Copyright 2022-
|
|
17
|
+
* Copyright 2022-2026 trebco, llc.
|
|
18
18
|
* info@treb.app
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
@@ -40,6 +40,13 @@ import type { CellStyle, ThemeColor } from 'treb-base-types';
|
|
|
40
40
|
import type { SerializedNamed } from 'treb-data-model';
|
|
41
41
|
import { type Metadata, ParseMetadataXML } from './metadata';
|
|
42
42
|
|
|
43
|
+
///////////////
|
|
44
|
+
|
|
45
|
+
import * as OOXML from 'ooxml-types';
|
|
46
|
+
import { ooxml_parser, IterateTags, MapTags, FirstTag } from './ooxml';
|
|
47
|
+
|
|
48
|
+
///////////////
|
|
49
|
+
|
|
43
50
|
/**
|
|
44
51
|
* @privateRemarks -- FIXME: not sure about the equal/equals thing. need to check.
|
|
45
52
|
*/
|
|
@@ -196,22 +203,24 @@ export class Workbook {
|
|
|
196
203
|
|
|
197
204
|
const rels: RelationshipMap = {};
|
|
198
205
|
const data = this.zip.Has(path) ? this.zip.Get(path) : '';
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
};
|
|
206
|
+
const root = ooxml_parser.parse(data);
|
|
207
|
+
|
|
208
|
+
if (root.Relationships) {
|
|
209
|
+
const relationships = root.Relationships as OOXML.Relationships;
|
|
210
|
+
IterateTags(relationships.Relationship, (relationship) => {
|
|
211
|
+
const id = relationship.$attributes?.Id;
|
|
212
|
+
if (id) {
|
|
213
|
+
rels[id] = {
|
|
214
|
+
id,
|
|
215
|
+
type: relationship.$attributes?.Type || '',
|
|
216
|
+
target: relationship.$attributes?.Target || '',
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
});
|
|
213
220
|
}
|
|
214
221
|
|
|
222
|
+
// console.info({rels});
|
|
223
|
+
|
|
215
224
|
return rels;
|
|
216
225
|
|
|
217
226
|
}
|
|
@@ -223,110 +232,98 @@ export class Workbook {
|
|
|
223
232
|
|
|
224
233
|
// shared strings
|
|
225
234
|
let data = this.zip.Has('xl/sharedStrings.xml') ? this.zip.Get('xl/sharedStrings.xml') : '';
|
|
226
|
-
let
|
|
227
|
-
|
|
235
|
+
let parsed = ooxml_parser.parse(data || '');
|
|
236
|
+
if (parsed.sst) {
|
|
237
|
+
this.shared_strings.FromXML(parsed.sst as OOXML.SharedStringTable);
|
|
238
|
+
}
|
|
228
239
|
|
|
229
|
-
//
|
|
240
|
+
// metadata
|
|
230
241
|
if (this.zip.Has('xl/metadata.xml')) {
|
|
231
242
|
data = this.zip.Get('xl/metadata.xml');
|
|
232
|
-
|
|
233
|
-
|
|
243
|
+
parsed = ooxml_parser.parse(data || '');
|
|
244
|
+
if (parsed.metadata) {
|
|
245
|
+
this.metadata = ParseMetadataXML(parsed.metadata as OOXML.Metadata);
|
|
246
|
+
}
|
|
234
247
|
}
|
|
235
248
|
|
|
236
249
|
// theme
|
|
237
250
|
data = this.zip.Get('xl/theme/theme1.xml');
|
|
238
|
-
|
|
239
|
-
|
|
251
|
+
parsed = ooxml_parser.parse(data);
|
|
252
|
+
if (parsed.theme) {
|
|
253
|
+
this.theme.FromXML(parsed.theme as OOXML.Theme);
|
|
254
|
+
}
|
|
240
255
|
|
|
241
256
|
// styles
|
|
242
257
|
data = this.zip.Get('xl/styles.xml');
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
258
|
+
parsed = ooxml_parser.parse(data);
|
|
259
|
+
if (parsed.styleSheet) {
|
|
260
|
+
this.style_cache.FromXML(parsed.styleSheet as OOXML.StyleSheet, this.theme);
|
|
261
|
+
}
|
|
247
262
|
|
|
248
263
|
// read workbook
|
|
249
264
|
data = this.zip.Get('xl/workbook.xml');
|
|
250
|
-
|
|
265
|
+
parsed = ooxml_parser.parse(data);
|
|
251
266
|
|
|
252
267
|
// defined names
|
|
253
|
-
|
|
254
|
-
const defined_names = XMLUtils.FindAll(xml, 'workbook/definedNames/definedName');
|
|
255
|
-
for (const defined_name of defined_names) {
|
|
256
|
-
const name = defined_name.a$?.name;
|
|
257
|
-
const expression = defined_name.t$ || '';
|
|
258
|
-
const sheet_index = (defined_name.a$?.localSheetId) ? Number(defined_name.a$.localSheetId) : undefined;
|
|
259
|
-
|
|
260
|
-
// console.info({defined_name, name, expression, sheet_index});
|
|
261
|
-
|
|
262
|
-
this.named.push({
|
|
263
|
-
name,
|
|
264
|
-
expression: typeof expression === 'string' ? expression : expression?.toString() || '',
|
|
265
|
-
local_scope: sheet_index,
|
|
266
|
-
});
|
|
268
|
+
if (parsed.workbook) {
|
|
267
269
|
|
|
268
|
-
|
|
270
|
+
const wb = parsed.workbook as OOXML.Workbook;
|
|
269
271
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
272
|
+
this.named = MapTags(wb.definedNames?.definedName, defined_name => {
|
|
273
|
+
return {
|
|
274
|
+
name: defined_name.$attributes?.name || '',
|
|
275
|
+
expression: defined_name.$text || '',
|
|
276
|
+
local_scope: defined_name.$attributes?.localSheetId,
|
|
277
|
+
};
|
|
278
|
+
});
|
|
273
279
|
|
|
274
|
-
|
|
280
|
+
const view = FirstTag(wb.bookViews?.workbookView);
|
|
281
|
+
this.active_tab = view?.$attributes?.activeTab ?? 0;
|
|
275
282
|
|
|
276
|
-
|
|
277
|
-
if (name && expression) {
|
|
278
|
-
this.defined_names[name] = expression;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
*/
|
|
282
|
-
|
|
283
|
-
const workbook_views = XMLUtils.FindAll(xml, 'workbook/bookViews/workbookView');
|
|
283
|
+
IterateTags(wb.sheets.sheet, element => {
|
|
284
284
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
285
|
+
const name = element.$attributes?.name;
|
|
286
|
+
if (name) {
|
|
288
287
|
|
|
289
|
-
|
|
290
|
-
|
|
288
|
+
const state = element.$attributes?.state;
|
|
289
|
+
const rid = element.$attributes?.id ?? '';
|
|
290
|
+
const id = element.$attributes?.sheetId;
|
|
291
291
|
|
|
292
|
+
const worksheet_path = `xl/${this.rels[rid].target}`;
|
|
293
|
+
data = this.zip.Get(worksheet_path);
|
|
294
|
+
parsed = ooxml_parser.parse(data);
|
|
295
|
+
if (parsed.worksheet) {
|
|
292
296
|
|
|
293
|
-
|
|
294
|
-
|
|
297
|
+
const root = parsed.worksheet as OOXML.Worksheet;
|
|
298
|
+
const worksheet = new Sheet({
|
|
299
|
+
name, rid, id,
|
|
300
|
+
}, root);
|
|
295
301
|
|
|
296
|
-
|
|
302
|
+
switch (state) {
|
|
303
|
+
case 'hidden':
|
|
304
|
+
worksheet.visible_state = VisibleState.hidden;
|
|
305
|
+
break;
|
|
297
306
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
if (state === 'hidden') {
|
|
306
|
-
worksheet.visible_state = VisibleState.hidden;
|
|
307
|
-
}
|
|
308
|
-
else if (state === 'veryHidden') {
|
|
309
|
-
worksheet.visible_state = VisibleState.very_hidden;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
worksheet.shared_strings = this.shared_strings;
|
|
307
|
+
case 'veryHidden':
|
|
308
|
+
worksheet.visible_state = VisibleState.hidden;
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
worksheet.shared_strings = this.shared_strings;
|
|
313
313
|
|
|
314
|
-
|
|
315
|
-
|
|
314
|
+
worksheet.path = worksheet_path;
|
|
315
|
+
worksheet.rels_path = worksheet.path.replace('worksheets', 'worksheets/_rels') + '.rels';
|
|
316
|
+
worksheet.rels = this.ReadRels(worksheet.rels_path);
|
|
316
317
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
worksheet.rels = this.ReadRels(worksheet.rels_path);
|
|
318
|
+
worksheet.Parse();
|
|
319
|
+
this.sheets.push(worksheet);
|
|
320
320
|
|
|
321
|
-
|
|
322
|
-
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
});
|
|
323
324
|
|
|
324
|
-
this.sheets.push(worksheet);
|
|
325
|
-
}
|
|
326
325
|
}
|
|
327
326
|
|
|
328
|
-
// console.info("TS", this.sheets);
|
|
329
|
-
|
|
330
327
|
|
|
331
328
|
}
|
|
332
329
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* You should have received a copy of the GNU General Public License along
|
|
15
15
|
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
16
|
*
|
|
17
|
-
* Copyright 2022-
|
|
17
|
+
* Copyright 2022-2026 trebco, llc.
|
|
18
18
|
* info@treb.app
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
@@ -125,8 +125,8 @@ export class NumberFormat {
|
|
|
125
125
|
public static minus_character = '-'; // hyphen
|
|
126
126
|
// public static minus_character = '−'; // minus
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
public magic_decimal = false;
|
|
128
|
+
/* * for the "General" format, a magic decimal point */
|
|
129
|
+
// public magic_decimal = false;
|
|
130
130
|
|
|
131
131
|
/**
|
|
132
132
|
* (testing) transformer. this is not rendered or persisted, like magic
|
|
@@ -595,11 +595,11 @@ export class NumberFormat {
|
|
|
595
595
|
}
|
|
596
596
|
else {
|
|
597
597
|
|
|
598
|
-
|
|
599
|
-
|
|
598
|
+
/*
|
|
600
599
|
if (this.magic_decimal && parts[1] === '') {
|
|
601
600
|
parts.splice(1, 1);
|
|
602
601
|
}
|
|
602
|
+
*/
|
|
603
603
|
|
|
604
604
|
text_parts = [
|
|
605
605
|
...(section.prefix.map((text_part) => {
|
|
@@ -936,7 +936,14 @@ export class NumberFormat {
|
|
|
936
936
|
|
|
937
937
|
const parts = representation.split('.');
|
|
938
938
|
|
|
939
|
+
if (parts.length === 2 && parts[1] === '' && section.decimal_min_digits === 0) {
|
|
940
|
+
parts.splice(1, 1);
|
|
941
|
+
}
|
|
942
|
+
|
|
939
943
|
while (parts[0].length < section.integer_min_digits) {
|
|
944
|
+
|
|
945
|
+
// this is sloppy
|
|
946
|
+
|
|
940
947
|
parts[0] = ('0000000000000000' + parts[0]).slice(-section.integer_min_digits);
|
|
941
948
|
}
|
|
942
949
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* You should have received a copy of the GNU General Public License along
|
|
15
15
|
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
16
|
*
|
|
17
|
-
* Copyright 2022-
|
|
17
|
+
* Copyright 2022-2026 trebco, llc.
|
|
18
18
|
* info@treb.app
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
@@ -169,12 +169,12 @@ export class NumberFormatCache {
|
|
|
169
169
|
// we're doing this to hide it, but we might as well allow it
|
|
170
170
|
// since js interfaces will find it regardless
|
|
171
171
|
|
|
172
|
-
this.cache['General'].magic_decimal = true;
|
|
172
|
+
// this.cache['General'].magic_decimal = true;
|
|
173
173
|
|
|
174
174
|
// special general type for complex has fewer digits by default
|
|
175
175
|
|
|
176
176
|
this.complex_general = new NumberFormat('0.###');
|
|
177
|
-
this.complex_general.magic_decimal = true;
|
|
177
|
+
// this.complex_general.magic_decimal = true;
|
|
178
178
|
|
|
179
179
|
for (const key of Object.keys(this.aliases)) {
|
|
180
180
|
this.cache[key] = this.cache[this.aliases[key]];
|
package/treb-format/src/index.ts
CHANGED