@node-projects/excelforge 2.4.0 → 3.0.0
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/.github/FUNDING.yml +4 -0
- package/MISSING.md +326 -0
- package/README.md +484 -12
- package/dist/core/SharedStrings.js +6 -2
- package/dist/core/SharedStrings.js.map +1 -1
- package/dist/core/Workbook.d.ts +41 -1
- package/dist/core/Workbook.js +773 -57
- package/dist/core/Workbook.js.map +1 -1
- package/dist/core/WorkbookReader.d.ts +18 -4
- package/dist/core/WorkbookReader.js +1386 -20
- package/dist/core/WorkbookReader.js.map +1 -1
- package/dist/core/Worksheet.d.ts +130 -2
- package/dist/core/Worksheet.js +792 -63
- package/dist/core/Worksheet.js.map +1 -1
- package/dist/core/types.d.ts +287 -5
- package/dist/core/types.js +12 -1
- package/dist/core/types.js.map +1 -1
- package/dist/features/ChartBuilder.d.ts +9 -1
- package/dist/features/ChartBuilder.js +140 -14
- package/dist/features/ChartBuilder.js.map +1 -1
- package/dist/features/CsvModule.d.ts +11 -0
- package/dist/features/CsvModule.js +137 -0
- package/dist/features/CsvModule.js.map +1 -0
- package/dist/features/Encryption.d.ts +6 -0
- package/dist/features/Encryption.js +806 -0
- package/dist/features/Encryption.js.map +1 -0
- package/dist/features/FormControlBuilder.d.ts +6 -0
- package/dist/features/FormControlBuilder.js +135 -0
- package/dist/features/FormControlBuilder.js.map +1 -0
- package/dist/features/FormulaEngine.d.ts +22 -0
- package/dist/features/FormulaEngine.js +498 -0
- package/dist/features/FormulaEngine.js.map +1 -0
- package/dist/features/HtmlModule.d.ts +21 -0
- package/dist/features/HtmlModule.js +1417 -0
- package/dist/features/HtmlModule.js.map +1 -0
- package/dist/features/JsonModule.d.ts +10 -0
- package/dist/features/JsonModule.js +76 -0
- package/dist/features/JsonModule.js.map +1 -0
- package/dist/features/PivotTableBuilder.d.ts +7 -0
- package/dist/features/PivotTableBuilder.js +170 -0
- package/dist/features/PivotTableBuilder.js.map +1 -0
- package/dist/features/Signing.d.ts +12 -0
- package/dist/features/Signing.js +318 -0
- package/dist/features/Signing.js.map +1 -0
- package/dist/features/TableBuilder.js +2 -2
- package/dist/features/TableBuilder.js.map +1 -1
- package/dist/index-min.js +579 -144
- package/dist/index.d.ts +17 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/styles/StyleRegistry.d.ts +14 -0
- package/dist/styles/StyleRegistry.js +95 -30
- package/dist/styles/StyleRegistry.js.map +1 -1
- package/dist/utils/helpers.d.ts +4 -0
- package/dist/utils/helpers.js +64 -14
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/zip.js +145 -73
- package/dist/utils/zip.js.map +1 -1
- package/dist/vba/VbaProject.d.ts +19 -0
- package/dist/vba/VbaProject.js +281 -0
- package/dist/vba/VbaProject.js.map +1 -0
- package/dist/vba/cfb.d.ts +7 -0
- package/dist/vba/cfb.js +352 -0
- package/dist/vba/cfb.js.map +1 -0
- package/dist/vba/ovba.d.ts +2 -0
- package/dist/vba/ovba.js +137 -0
- package/dist/vba/ovba.js.map +1 -0
- package/package.json +4 -3
- package/validator.cs +0 -155
- package/validatorEpplus.cs +0 -27
- package/validatorReadData.cs +0 -111
package/README.md
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# ExcelForge 📊
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://badge.fury.io/js/%40node-projects%2Fexcelforge)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
A **complete TypeScript library** for reading and writing Excel `.xlsx` and `.xlsm` (macro-enabled) files with **zero external dependencies**. Works in browsers, Node.js, Deno, Bun, and edge runtimes.
|
|
7
|
+
|
|
8
|
+
ExcelForge gives you the full power of the OOXML spec — including real DEFLATE compression, round-trip editing of existing files, and rich property support.
|
|
6
9
|
|
|
7
10
|
---
|
|
8
11
|
|
|
@@ -13,22 +16,38 @@ Inspired by EPPlus (C#), ExcelForge gives you the full power of the OOXML spec
|
|
|
13
16
|
| **Read existing files** | Load `.xlsx` from file, `Uint8Array`, `base64`, or `Blob` |
|
|
14
17
|
| **Patch-only writes** | Re-serialise only changed sheets; preserve pivot tables, VBA, charts, unknown parts verbatim |
|
|
15
18
|
| **Compression** | Full LZ77 + Huffman DEFLATE (levels 0–9). Typical XML compresses 80–85% |
|
|
16
|
-
| **Cell Values** | Strings, numbers, booleans, dates, formulas, array formulas, rich text |
|
|
19
|
+
| **Cell Values** | Strings, numbers, booleans, dates, formulas, array formulas, dynamic arrays, shared formulas, rich text |
|
|
17
20
|
| **Styles** | Fonts, solid/pattern/gradient fills, all border styles, alignment, 30+ number format presets |
|
|
18
21
|
| **Layout** | Merge cells, freeze/split panes, column widths, row heights, hide rows/cols, outline grouping |
|
|
19
|
-
| **Charts** | Bar, column (stacked/100%), line, area, pie, doughnut, scatter, radar, bubble |
|
|
20
|
-
| **Images** | PNG, JPEG, GIF — two-cell
|
|
21
|
-
| **
|
|
22
|
-
| **
|
|
22
|
+
| **Charts** | Bar, column (stacked/100%), line, area, pie, doughnut, scatter, radar, bubble; chart sheets; modern styling with 18 color palettes, gradients, data labels, shadows; chart templates |
|
|
23
|
+
| **Images** | PNG, JPEG, GIF, BMP, SVG, WebP, ICO, EMF, WMF, TIFF — two-cell, one-cell, or absolute anchors |
|
|
24
|
+
| **In-Cell Pictures** | Embed images directly inside cells via richData/metadata (Excel 365+) |
|
|
25
|
+
| **Shapes** | 28 preset shapes (rect, ellipse, arrows, flowchart, etc.) with fill, line, text, rotation |
|
|
26
|
+
| **WordArt** | Text effects with 20 preset transforms (arch, wave, inflate, etc.) |
|
|
27
|
+
| **Tables** | Styled Excel tables with totals row, filter buttons, custom table styles, table slicers |
|
|
28
|
+
| **Conditional Formatting** | Cell rules, color scales, data bars, icon sets (incl. custom), cross-worksheet refs |
|
|
23
29
|
| **Data Validation** | Dropdowns, whole number, decimal, date, time, text length, custom formula |
|
|
24
30
|
| **Sparklines** | Line, bar, stacked — with high/low/first/last/negative colors |
|
|
25
|
-
| **
|
|
31
|
+
| **Pivot Tables** | Row/column/data fields, aggregation, calculated fields, grouping, custom styles, slicers |
|
|
32
|
+
| **Page Setup** | Paper size, orientation, margins, headers/footers (odd/even/first), print options, page breaks |
|
|
26
33
|
| **Protection** | Sheet protection with password, cell locking/hiding |
|
|
27
34
|
| **Named Ranges** | Workbook and sheet-scoped |
|
|
28
|
-
| **
|
|
35
|
+
| **Connections** | OLEDB, ODBC, text/CSV, web — create, read, round-trip; query tables |
|
|
36
|
+
| **Power Query** | Read M formulas from DataMashup; full round-trip preservation |
|
|
37
|
+
| **External Links** | Cross-workbook references with sheet names and defined names |
|
|
38
|
+
| **VBA Macros** | Create/read `.xlsm` with standard modules, class modules, document modules; code signing; full round-trip |
|
|
39
|
+
| **Auto Filter** | Dropdown filters — value, date, custom, top-10, dynamic filters |
|
|
29
40
|
| **Hyperlinks** | External URLs, mailto, internal navigation |
|
|
30
|
-
| **
|
|
41
|
+
| **Form Controls** | Button, checkbox, combobox, listbox, radio, groupbox, label, scrollbar, spinner — with macro assignment |
|
|
42
|
+
| **Dialog Sheets** | Excel 5 dialog sheets with dialog frame, OK/Cancel buttons, combo boxes |
|
|
43
|
+
| **Comments** | Cell comments with author, rich text formatting |
|
|
44
|
+
| **Themes** | Full Office theme XML with customizable colors and fonts |
|
|
31
45
|
| **Multiple Sheets** | Any number, hidden/veryHidden, tab colors |
|
|
46
|
+
| **Formula Engine** | 60+ functions including GETPIVOTDATA — tree-shakeable |
|
|
47
|
+
| **Export** | CSV, JSON, HTML (with CF visualization, sparklines, charts, shapes, form controls) |
|
|
48
|
+
| **Encryption** | OOXML Agile Encryption with AES-256-CBC + SHA-512 via Web Crypto API |
|
|
49
|
+
| **Digital Signatures** | Package signing (XML-DSig) + VBA code signing (PKCS#7/CMS, SHA-256) |
|
|
50
|
+
| **Locale** | Configurable decimal/thousands separators, date format, currency symbol |
|
|
32
51
|
| **Core Properties** | Title, author, subject, keywords, description, language, revision, category… |
|
|
33
52
|
| **Extended Properties** | Company, manager, application, appVersion, hyperlinkBase, word/line/page counts… |
|
|
34
53
|
| **Custom Properties** | Typed key-value store: string, int, decimal, bool, date, r8, i8 |
|
|
@@ -383,18 +402,212 @@ ws.addChart({
|
|
|
383
402
|
|
|
384
403
|
Supported chart types: `bar`, `col`, `colStacked`, `col100`, `barStacked`, `bar100`, `line`, `lineStacked`, `area`, `pie`, `doughnut`, `scatter`, `radar`, `bubble`.
|
|
385
404
|
|
|
405
|
+
**Modern chart styling (Excel 2019+):**
|
|
406
|
+
|
|
407
|
+
```typescript
|
|
408
|
+
ws.addChart({
|
|
409
|
+
type: 'column',
|
|
410
|
+
title: 'Styled Chart',
|
|
411
|
+
series: [{
|
|
412
|
+
name: 'Revenue', values: "'Sheet1'!$A$2:$D$2",
|
|
413
|
+
dataLabels: { showValue: true, position: 'outEnd' },
|
|
414
|
+
fillType: 'gradient',
|
|
415
|
+
gradientStops: [{ pos: 0, color: '4472C4' }, { pos: 100, color: 'B4C7E7' }],
|
|
416
|
+
}],
|
|
417
|
+
from: { col: 0, row: 5 }, to: { col: 8, row: 20 },
|
|
418
|
+
colorPalette: 'blue', // 18 palettes: office, blue, orange, green, red, purple, teal...
|
|
419
|
+
shadow: true,
|
|
420
|
+
roundedCorners: true,
|
|
421
|
+
dataLabels: { showPercent: true }, // global data labels
|
|
422
|
+
});
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
**Chart templates:**
|
|
426
|
+
|
|
427
|
+
```typescript
|
|
428
|
+
import { saveChartTemplate, applyChartTemplate, serializeChartTemplate, deserializeChartTemplate } from 'excelforge';
|
|
429
|
+
|
|
430
|
+
// Save a chart's style as a template
|
|
431
|
+
const template = saveChartTemplate(chart);
|
|
432
|
+
const json = serializeChartTemplate(template); // serialize to JSON string
|
|
433
|
+
const restored = deserializeChartTemplate(json); // deserialize back
|
|
434
|
+
|
|
435
|
+
// Apply template to a new chart
|
|
436
|
+
const newChart = applyChartTemplate(template, {
|
|
437
|
+
series: [{ name: 'New', values: "'Sheet1'!$A$1:$A$5" }],
|
|
438
|
+
from: { col: 0, row: 0 }, to: { col: 5, row: 10 },
|
|
439
|
+
});
|
|
440
|
+
```
|
|
441
|
+
|
|
386
442
|
### Images
|
|
387
443
|
|
|
444
|
+
Supported formats: `png`, `jpeg`, `gif`, `bmp`, `svg`, `webp`, `ico`, `emf`, `wmf`, `tiff`.
|
|
445
|
+
|
|
388
446
|
```typescript
|
|
389
447
|
import { readFileSync } from 'fs';
|
|
390
448
|
const imgData = readFileSync('./logo.png');
|
|
391
449
|
|
|
450
|
+
// Floating image (two-cell anchor)
|
|
392
451
|
ws.addImage({
|
|
393
452
|
data: imgData, // Buffer, Uint8Array, or base64 string
|
|
394
453
|
format: 'png',
|
|
395
454
|
from: { row: 1, col: 1 },
|
|
396
455
|
to: { row: 8, col: 4 },
|
|
397
456
|
});
|
|
457
|
+
|
|
458
|
+
// One-cell anchor with explicit pixel size
|
|
459
|
+
ws.addImage({
|
|
460
|
+
data: readFileSync('./icon.svg'),
|
|
461
|
+
format: 'svg',
|
|
462
|
+
from: { row: 1, col: 6 },
|
|
463
|
+
width: 80,
|
|
464
|
+
height: 80,
|
|
465
|
+
altText: 'Company icon',
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
// Absolute positioning (not tied to any cell)
|
|
469
|
+
ws.addImage({
|
|
470
|
+
data: imgData,
|
|
471
|
+
format: 'png',
|
|
472
|
+
position: { x: 200, y: 100 }, // pixels from top-left of sheet
|
|
473
|
+
width: 120,
|
|
474
|
+
height: 80,
|
|
475
|
+
});
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
### In-Cell Pictures
|
|
479
|
+
|
|
480
|
+
Embed images directly inside cells (Excel 365+ feature). Uses richData/metadata internally.
|
|
481
|
+
|
|
482
|
+
```typescript
|
|
483
|
+
import type { CellImage } from '@node-projects/excelforge';
|
|
484
|
+
|
|
485
|
+
ws.addCellImage({
|
|
486
|
+
data: readFileSync('./photo.png'),
|
|
487
|
+
format: 'png',
|
|
488
|
+
cell: 'B2', // cell reference
|
|
489
|
+
altText: 'Product photo',
|
|
490
|
+
});
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
### Pivot tables
|
|
494
|
+
|
|
495
|
+
```typescript
|
|
496
|
+
const wb = new Workbook();
|
|
497
|
+
|
|
498
|
+
// Source data sheet
|
|
499
|
+
const wsData = wb.addSheet('Data');
|
|
500
|
+
wsData.writeRow(1, 1, ['Region', 'Product', 'Sales', 'Units']);
|
|
501
|
+
wsData.writeArray(2, 1, [
|
|
502
|
+
['North', 'Widget', 12000, 150],
|
|
503
|
+
['South', 'Widget', 9500, 120],
|
|
504
|
+
['North', 'Gadget', 8700, 90],
|
|
505
|
+
['South', 'Gadget', 11200, 140],
|
|
506
|
+
]);
|
|
507
|
+
|
|
508
|
+
// Pivot table on a separate sheet
|
|
509
|
+
const wsPivot = wb.addSheet('Summary');
|
|
510
|
+
wsPivot.addPivotTable({
|
|
511
|
+
name: 'SalesBreakdown',
|
|
512
|
+
sourceSheet: 'Data',
|
|
513
|
+
sourceRef: 'A1:D5',
|
|
514
|
+
targetCell: 'A1',
|
|
515
|
+
rowFields: ['Region'],
|
|
516
|
+
colFields: ['Product'],
|
|
517
|
+
dataFields: [{ field: 'Sales', name: 'Sum of Sales', func: 'sum' }],
|
|
518
|
+
style: 'PivotStyleMedium9',
|
|
519
|
+
rowGrandTotals: true,
|
|
520
|
+
colGrandTotals: true,
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
await wb.writeFile('./pivot_report.xlsx');
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
Available aggregation functions: `sum`, `count`, `average`, `max`, `min`, `product`, `countNums`, `stdDev`, `stdDevp`, `var`, `varp`.
|
|
527
|
+
|
|
528
|
+
### VBA macros
|
|
529
|
+
|
|
530
|
+
ExcelForge can create, read, and round-trip `.xlsm` files with VBA macros. All module types are supported: standard modules, class modules, and document modules (auto-created for `ThisWorkbook` and each worksheet).
|
|
531
|
+
|
|
532
|
+
```typescript
|
|
533
|
+
import { Workbook, VbaProject } from './src/index.js';
|
|
534
|
+
|
|
535
|
+
const wb = new Workbook();
|
|
536
|
+
const ws = wb.addSheet('Sheet1');
|
|
537
|
+
ws.setValue(1, 1, 'Hello');
|
|
538
|
+
|
|
539
|
+
const vba = new VbaProject();
|
|
540
|
+
|
|
541
|
+
// Standard module
|
|
542
|
+
vba.addModule({
|
|
543
|
+
name: 'Module1',
|
|
544
|
+
type: 'standard',
|
|
545
|
+
code: 'Sub HelloWorld()\r\n MsgBox "Hello from VBA!"\r\nEnd Sub\r\n',
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
// Class module
|
|
549
|
+
vba.addModule({
|
|
550
|
+
name: 'MyClass',
|
|
551
|
+
type: 'class',
|
|
552
|
+
code: [
|
|
553
|
+
'Private pValue As String',
|
|
554
|
+
'Public Property Get Value() As String',
|
|
555
|
+
' Value = pValue',
|
|
556
|
+
'End Property',
|
|
557
|
+
'Public Property Let Value(v As String)',
|
|
558
|
+
' pValue = v',
|
|
559
|
+
'End Property',
|
|
560
|
+
].join('\r\n') + '\r\n',
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
wb.vbaProject = vba;
|
|
564
|
+
await wb.writeFile('./macros.xlsm'); // must use .xlsm extension
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
Reading VBA from existing files:
|
|
568
|
+
|
|
569
|
+
```typescript
|
|
570
|
+
const wb = await Workbook.fromFile('./macros.xlsm');
|
|
571
|
+
if (wb.vbaProject) {
|
|
572
|
+
for (const mod of wb.vbaProject.modules) {
|
|
573
|
+
console.log(`${mod.name} (${mod.type}): ${mod.code.length} chars`);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// Modify and re-save — existing modules are preserved
|
|
578
|
+
wb.vbaProject.addModule({ name: 'Module2', type: 'standard', code: '...' });
|
|
579
|
+
wb.vbaProject.removeModule('OldModule');
|
|
580
|
+
await wb.writeFile('./macros_updated.xlsm');
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
> **Note:** Document modules for `ThisWorkbook` and each worksheet are automatically created if not explicitly provided. VBA code uses `\r\n` line endings.
|
|
584
|
+
|
|
585
|
+
### Digital Signatures
|
|
586
|
+
|
|
587
|
+
Sign OOXML packages and VBA projects using RSA with SHA-256 via Web Crypto API.
|
|
588
|
+
|
|
589
|
+
```typescript
|
|
590
|
+
import { signPackage, signVbaProject, signWorkbook } from 'excelforge';
|
|
591
|
+
|
|
592
|
+
// Sign the entire package
|
|
593
|
+
const parts = new Map<string, Uint8Array>();
|
|
594
|
+
parts.set('xl/workbook.xml', workbookBytes);
|
|
595
|
+
parts.set('xl/worksheets/sheet1.xml', sheetBytes);
|
|
596
|
+
|
|
597
|
+
const sigEntries = await signPackage(parts, {
|
|
598
|
+
certificate: pemCertificate, // PEM-encoded X.509 certificate
|
|
599
|
+
privateKey: pemPrivateKey, // PEM-encoded PKCS#8 private key
|
|
600
|
+
});
|
|
601
|
+
// sigEntries contains _xmlsignatures/sig1.xml, origin.sigs, and rels
|
|
602
|
+
|
|
603
|
+
// Sign a VBA project
|
|
604
|
+
const vbaSignature = await signVbaProject(vbaProjectBin, {
|
|
605
|
+
certificate: pemCertificate,
|
|
606
|
+
privateKey: pemPrivateKey,
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
// Or sign both at once
|
|
610
|
+
const result = await signWorkbook(parts, { certificate, privateKey }, vbaProjectBin);
|
|
398
611
|
```
|
|
399
612
|
|
|
400
613
|
### Page setup
|
|
@@ -420,6 +633,244 @@ ws.headerFooter = {
|
|
|
420
633
|
};
|
|
421
634
|
```
|
|
422
635
|
|
|
636
|
+
### Page breaks
|
|
637
|
+
|
|
638
|
+
```typescript
|
|
639
|
+
// Add manual page breaks for printing
|
|
640
|
+
ws.addRowBreak(20); // page break after row 20
|
|
641
|
+
ws.addRowBreak(40); // page break after row 40
|
|
642
|
+
ws.addColBreak(5); // page break after column E
|
|
643
|
+
|
|
644
|
+
// Read page breaks from an existing file
|
|
645
|
+
const wb = await Workbook.fromBytes(data);
|
|
646
|
+
const ws = wb.getSheet('Sheet1')!;
|
|
647
|
+
for (const brk of ws.getRowBreaks()) {
|
|
648
|
+
console.log(`Row break at ${brk.id}, manual: ${brk.manual}`);
|
|
649
|
+
}
|
|
650
|
+
for (const brk of ws.getColBreaks()) {
|
|
651
|
+
console.log(`Col break at ${brk.id}, manual: ${brk.manual}`);
|
|
652
|
+
}
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
Page breaks are fully preserved during round-trip editing, even when sheets are modified.
|
|
656
|
+
|
|
657
|
+
### Named ranges
|
|
658
|
+
|
|
659
|
+
```typescript
|
|
660
|
+
// Define workbook-scoped named ranges
|
|
661
|
+
wb.addNamedRange({ name: 'SalesData', ref: 'Data!$A$1:$A$5' });
|
|
662
|
+
wb.addNamedRange({ name: 'Products', ref: 'Data!$B$1:$B$5', comment: 'Product list' });
|
|
663
|
+
|
|
664
|
+
// Define sheet-scoped named range
|
|
665
|
+
wb.addNamedRange({ name: 'LocalTotal', ref: 'Data!$A$6', scope: 'Data' });
|
|
666
|
+
|
|
667
|
+
// Use in formulas
|
|
668
|
+
ws.setFormula(1, 1, 'SUM(SalesData)');
|
|
669
|
+
|
|
670
|
+
// Read named ranges from an existing file
|
|
671
|
+
const wb2 = await Workbook.fromBytes(data);
|
|
672
|
+
const ranges = wb2.getNamedRanges(); // all named ranges
|
|
673
|
+
const sales = wb2.getNamedRange('SalesData'); // find by name
|
|
674
|
+
console.log(sales?.ref); // "Data!$A$1:$A$5"
|
|
675
|
+
|
|
676
|
+
// Remove a named range
|
|
677
|
+
wb2.removeNamedRange('SalesData');
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
Named ranges (including scope and comments) are fully preserved during round-trip editing.
|
|
681
|
+
|
|
682
|
+
### Connections & Power Query
|
|
683
|
+
|
|
684
|
+
```typescript
|
|
685
|
+
// Add a data connection (OLEDB, ODBC, text/CSV, web, etc.)
|
|
686
|
+
wb.addConnection({
|
|
687
|
+
id: 1,
|
|
688
|
+
name: 'SalesDB',
|
|
689
|
+
type: 'oledb', // 'odbc' | 'dao' | 'file' | 'web' | 'oledb' | 'text' | 'dsp'
|
|
690
|
+
connectionString: 'Provider=SQLOLEDB;Data Source=server;Initial Catalog=Sales;',
|
|
691
|
+
command: 'SELECT * FROM Orders',
|
|
692
|
+
commandType: 'sql', // 'sql' | 'table' | 'default' | 'web' | 'oledb'
|
|
693
|
+
description: 'Sales database connection',
|
|
694
|
+
background: true,
|
|
695
|
+
saveData: true,
|
|
696
|
+
});
|
|
697
|
+
|
|
698
|
+
// Read connections from an existing file
|
|
699
|
+
const wb2 = await Workbook.fromBytes(data);
|
|
700
|
+
const conns = wb2.getConnections(); // all connections
|
|
701
|
+
const sales = wb2.getConnection('SalesDB'); // find by name
|
|
702
|
+
wb2.removeConnection('SalesDB'); // remove by name
|
|
703
|
+
|
|
704
|
+
// Read Power Query M formulas (extracted from DataMashup)
|
|
705
|
+
const queries = wb2.getPowerQueries(); // all queries
|
|
706
|
+
const q = wb2.getPowerQuery('MyQuery'); // find by name
|
|
707
|
+
console.log(q?.formula); // Power Query M code
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
Connections are fully preserved during round-trip editing. Power Query formulas (M code) stored in DataMashup binary blobs are automatically extracted for read access. Power Query/Power Pivot data models created in Excel are preserved verbatim during round-trip — you can safely open, modify cells, and save without losing any Power Query or Power Pivot features.
|
|
711
|
+
|
|
712
|
+
### Form Controls
|
|
713
|
+
|
|
714
|
+
```typescript
|
|
715
|
+
// Add a button with a macro
|
|
716
|
+
ws.addFormControl({
|
|
717
|
+
type: 'button',
|
|
718
|
+
from: { col: 1, row: 2 },
|
|
719
|
+
to: { col: 3, row: 4 },
|
|
720
|
+
text: 'Run Report',
|
|
721
|
+
macro: 'Sheet1.RunReport',
|
|
722
|
+
});
|
|
723
|
+
|
|
724
|
+
// Button sized by width/height (no 'to' anchor needed)
|
|
725
|
+
ws.addFormControl({
|
|
726
|
+
type: 'button',
|
|
727
|
+
from: { col: 1, row: 5 },
|
|
728
|
+
width: 120, height: 30, // pixels
|
|
729
|
+
text: 'Compact Button',
|
|
730
|
+
});
|
|
731
|
+
|
|
732
|
+
// CheckBox linked to a cell
|
|
733
|
+
ws.addFormControl({
|
|
734
|
+
type: 'checkBox',
|
|
735
|
+
from: { col: 1, row: 7 },
|
|
736
|
+
to: { col: 3, row: 8 },
|
|
737
|
+
text: 'Enable Feature',
|
|
738
|
+
linkedCell: '$B$10',
|
|
739
|
+
checked: 'checked', // 'checked' | 'unchecked' | 'mixed'
|
|
740
|
+
});
|
|
741
|
+
|
|
742
|
+
// ComboBox (dropdown) with input range
|
|
743
|
+
ws.addFormControl({
|
|
744
|
+
type: 'comboBox',
|
|
745
|
+
from: { col: 1, row: 7 },
|
|
746
|
+
to: { col: 3, row: 8 },
|
|
747
|
+
linkedCell: '$B$11',
|
|
748
|
+
inputRange: '$D$1:$D$5',
|
|
749
|
+
dropLines: 5,
|
|
750
|
+
});
|
|
751
|
+
|
|
752
|
+
// ListBox, OptionButton, GroupBox, Label, ScrollBar, Spinner
|
|
753
|
+
ws.addFormControl({
|
|
754
|
+
type: 'scrollBar',
|
|
755
|
+
from: { col: 4, row: 6 },
|
|
756
|
+
to: { col: 6, row: 7 },
|
|
757
|
+
linkedCell: '$B$14',
|
|
758
|
+
min: 0, max: 100, inc: 1, page: 10, val: 50,
|
|
759
|
+
});
|
|
760
|
+
|
|
761
|
+
// Read form controls from an existing file
|
|
762
|
+
const wb2 = await Workbook.fromBytes(data);
|
|
763
|
+
const controls = ws.getFormControls();
|
|
764
|
+
for (const ctrl of controls) {
|
|
765
|
+
console.log(ctrl.type, ctrl.linkedCell, ctrl.macro);
|
|
766
|
+
}
|
|
767
|
+
```
|
|
768
|
+
|
|
769
|
+
Supported control types: `button`, `checkBox`, `comboBox`, `listBox`, `optionButton`, `groupBox`, `label`, `scrollBar`, `spinner`. All control types support `macro` assignment and are fully preserved during round-trip editing.
|
|
770
|
+
|
|
771
|
+
### Shapes
|
|
772
|
+
|
|
773
|
+
```typescript
|
|
774
|
+
ws.addShape({
|
|
775
|
+
type: 'roundRect',
|
|
776
|
+
from: { col: 1, row: 3 },
|
|
777
|
+
to: { col: 5, row: 8 },
|
|
778
|
+
fillColor: '4472C4',
|
|
779
|
+
lineColor: '2F5496',
|
|
780
|
+
text: 'Process Step',
|
|
781
|
+
rotation: 0,
|
|
782
|
+
});
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
Supported shape types: `rect`, `roundRect`, `ellipse`, `triangle`, `diamond`, `pentagon`, `hexagon`, `octagon`, `star5`, `star6`, `rightArrow`, `leftArrow`, `upArrow`, `downArrow`, `line`, `curvedConnector3`, `callout1`, `callout2`, `cloud`, `heart`, `lightningBolt`, `sun`, `moon`, `smileyFace`, `flowChartProcess`, `flowChartDecision`, `flowChartTerminator`, `flowChartDocument`.
|
|
786
|
+
|
|
787
|
+
### WordArt
|
|
788
|
+
|
|
789
|
+
```typescript
|
|
790
|
+
ws.addWordArt({
|
|
791
|
+
text: 'SALE!',
|
|
792
|
+
preset: 'textArchUp',
|
|
793
|
+
font: { name: 'Impact', size: 48, bold: true },
|
|
794
|
+
fillColor: 'FF0000',
|
|
795
|
+
outlineColor: '990000',
|
|
796
|
+
from: { col: 1, row: 1 },
|
|
797
|
+
to: { col: 8, row: 6 },
|
|
798
|
+
});
|
|
799
|
+
```
|
|
800
|
+
|
|
801
|
+
Supported presets: `textPlain`, `textArchUp`, `textArchDown`, `textCircle`, `textWave1`, `textWave2`, `textInflate`, `textDeflate`, `textFadeUp`, `textFadeDown`, `textSlantUp`, `textSlantDown`, and more.
|
|
802
|
+
|
|
803
|
+
### Themes
|
|
804
|
+
|
|
805
|
+
```typescript
|
|
806
|
+
wb.theme = {
|
|
807
|
+
name: 'Corporate Theme',
|
|
808
|
+
colors: [
|
|
809
|
+
{ name: 'dk1', color: '000000' }, { name: 'lt1', color: 'FFFFFF' },
|
|
810
|
+
{ name: 'dk2', color: '44546A' }, { name: 'lt2', color: 'E7E6E6' },
|
|
811
|
+
{ name: 'accent1', color: '4472C4' }, { name: 'accent2', color: 'ED7D31' },
|
|
812
|
+
{ name: 'accent3', color: 'A5A5A5' }, { name: 'accent4', color: 'FFC000' },
|
|
813
|
+
{ name: 'accent5', color: '5B9BD5' }, { name: 'accent6', color: '70AD47' },
|
|
814
|
+
{ name: 'hlink', color: '0563C1' }, { name: 'folHlink', color: '954F72' },
|
|
815
|
+
],
|
|
816
|
+
majorFont: 'Calibri Light',
|
|
817
|
+
minorFont: 'Calibri',
|
|
818
|
+
};
|
|
819
|
+
```
|
|
820
|
+
|
|
821
|
+
### Table Slicers
|
|
822
|
+
|
|
823
|
+
```typescript
|
|
824
|
+
ws.addTableSlicer({
|
|
825
|
+
name: 'RegionSlicer',
|
|
826
|
+
tableName: 'SalesTable',
|
|
827
|
+
columnName: 'Region',
|
|
828
|
+
caption: 'Filter by Region',
|
|
829
|
+
style: 'SlicerStyleLight1',
|
|
830
|
+
});
|
|
831
|
+
```
|
|
832
|
+
|
|
833
|
+
### Pivot Slicers & Custom Pivot Styles
|
|
834
|
+
|
|
835
|
+
```typescript
|
|
836
|
+
wb.registerPivotStyle({
|
|
837
|
+
name: 'BrandedPivot',
|
|
838
|
+
elements: [
|
|
839
|
+
{ type: 'headerRow', style: { font: { bold: true, color: 'FFFFFF' }, fill: { type: 'pattern', pattern: 'solid', fgColor: '4472C4' } } },
|
|
840
|
+
],
|
|
841
|
+
});
|
|
842
|
+
|
|
843
|
+
wb.addPivotSlicer({
|
|
844
|
+
name: 'ProductSlicer',
|
|
845
|
+
pivotTableName: 'SalesPivot',
|
|
846
|
+
fieldName: 'Product',
|
|
847
|
+
caption: 'Product Filter',
|
|
848
|
+
});
|
|
849
|
+
```
|
|
850
|
+
|
|
851
|
+
### External Links
|
|
852
|
+
|
|
853
|
+
```typescript
|
|
854
|
+
wb.addExternalLink({
|
|
855
|
+
target: 'file:///C:/Reports/Budget.xlsx',
|
|
856
|
+
sheets: [{ name: 'Sheet1' }, { name: 'Summary' }],
|
|
857
|
+
});
|
|
858
|
+
|
|
859
|
+
// Reference external data in formulas
|
|
860
|
+
ws.setFormula(1, 1, '[1]Sheet1!A1');
|
|
861
|
+
```
|
|
862
|
+
|
|
863
|
+
### Locale Settings
|
|
864
|
+
|
|
865
|
+
```typescript
|
|
866
|
+
wb.locale = {
|
|
867
|
+
decimalSeparator: ',',
|
|
868
|
+
thousandsSeparator: '.',
|
|
869
|
+
dateFormat: 'DD.MM.YYYY',
|
|
870
|
+
currencySymbol: '€',
|
|
871
|
+
};
|
|
872
|
+
```
|
|
873
|
+
|
|
423
874
|
### Sheet protection
|
|
424
875
|
|
|
425
876
|
```typescript
|
|
@@ -498,8 +949,15 @@ ExcelForge
|
|
|
498
949
|
│ ├── StyleRegistry.ts — interns fonts/fills/borders/xfs, emits styles.xml
|
|
499
950
|
│ └── builders.ts — fluent style() builder, Colors/NumFmt/Styles presets
|
|
500
951
|
├── features/
|
|
501
|
-
│ ├── ChartBuilder.ts — DrawingML chart XML for 15+ chart types
|
|
502
|
-
│
|
|
952
|
+
│ ├── ChartBuilder.ts — DrawingML chart XML for 15+ chart types, templates, modern styling
|
|
953
|
+
│ ├── TableBuilder.ts — Excel table XML
|
|
954
|
+
│ ├── PivotTableBuilder.ts — pivot table + cache XML
|
|
955
|
+
│ ├── Encryption.ts — OOXML Agile Encryption (AES-256-CBC + SHA-512)
|
|
956
|
+
│ └── Signing.ts — Digital signatures (XML-DSig + VBA PKCS#7/CMS)
|
|
957
|
+
├── vba/
|
|
958
|
+
│ ├── VbaProject.ts — VBA project build/parse, module management
|
|
959
|
+
│ ├── cfb.ts — Compound Binary File (OLE2) reader & writer
|
|
960
|
+
│ └── ovba.ts — MS-OVBA compression/decompression
|
|
503
961
|
└── utils/
|
|
504
962
|
├── zip.ts — ZIP writer with full LZ77+Huffman DEFLATE
|
|
505
963
|
├── zipReader.ts — ZIP reader (STORE + DEFLATE via DecompressionStream)
|
|
@@ -553,6 +1011,20 @@ document.getElementById('file').addEventListener('change', async (e) => {
|
|
|
553
1011
|
|
|
554
1012
|
## Changelog
|
|
555
1013
|
|
|
1014
|
+
### v3.0 — More
|
|
1015
|
+
- **Form Controls** - create Form Controls
|
|
1016
|
+
- Wordart
|
|
1017
|
+
- Formula Objects
|
|
1018
|
+
- Chart Pages
|
|
1019
|
+
- Many more features....
|
|
1020
|
+
|
|
1021
|
+
### v2.4 — Pivot Tables & VBA Macros
|
|
1022
|
+
|
|
1023
|
+
- **Pivot tables** — create pivot tables with row/column/data fields, 11 aggregation functions, customisable styles
|
|
1024
|
+
- **VBA macros** — create, read, and round-trip `.xlsm` files with standard, class, and document modules
|
|
1025
|
+
- **CFB (OLE2) support** — MS-CFB reader/writer for vbaProject.bin, with MS-OVBA compression
|
|
1026
|
+
- **Automatic sheet modules** — document modules for ThisWorkbook and each worksheet are auto-generated
|
|
1027
|
+
|
|
556
1028
|
### v2.0 — Read, Modify, Compress
|
|
557
1029
|
|
|
558
1030
|
- **Read existing XLSX files** — `Workbook.fromFile()`, `fromBytes()`, `fromBase64()`, `fromBlob()`
|
|
@@ -58,8 +58,12 @@ function richFontXml(f) {
|
|
|
58
58
|
parts.push(`<u val="${f.underline}"/>`);
|
|
59
59
|
if (f.size)
|
|
60
60
|
parts.push(`<sz val="${f.size}"/>`);
|
|
61
|
-
if (f.color)
|
|
62
|
-
|
|
61
|
+
if (f.color) {
|
|
62
|
+
if (f.color.startsWith('theme:'))
|
|
63
|
+
parts.push(`<color theme="${f.color.slice(6)}"/>`);
|
|
64
|
+
else
|
|
65
|
+
parts.push(`<color rgb="${f.color.startsWith('#') ? 'FF' + f.color.slice(1) : f.color}"/>`);
|
|
66
|
+
}
|
|
63
67
|
if (f.name)
|
|
64
68
|
parts.push(`<name val="${escapeXml(f.name)}"/>`);
|
|
65
69
|
return parts.length ? `<rPr>${par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,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC;IACjG,CAAC;IACD,IAAI,CAAC,CAAC,IAAI;QAAI,KAAK,CAAC,IAAI,CAAC,cAAc,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/D,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5D,CAAC"}
|
package/dist/core/Workbook.d.ts
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import type { WorkbookProperties, NamedRange, WorksheetOptions } from '../core/types.js';
|
|
1
|
+
import type { WorkbookProperties, NamedRange, WorksheetOptions, Connection, PowerQuery, Theme, ExternalLink, CustomPivotStyle, LocaleSettings, PivotSlicer } from '../core/types.js';
|
|
2
2
|
import { Worksheet } from './Worksheet.js';
|
|
3
|
+
import { VbaProject } from '../vba/VbaProject.js';
|
|
3
4
|
import { type CoreProperties, type ExtendedProperties, type CustomProperty } from './properties.js';
|
|
4
5
|
export declare class Workbook {
|
|
5
6
|
private sheets;
|
|
6
7
|
private namedRanges;
|
|
8
|
+
private connections;
|
|
9
|
+
private powerQueries;
|
|
10
|
+
private externalLinks;
|
|
11
|
+
private customPivotStyles;
|
|
12
|
+
private pivotSlicers;
|
|
13
|
+
theme?: Theme;
|
|
14
|
+
locale?: LocaleSettings;
|
|
7
15
|
properties: WorkbookProperties;
|
|
8
16
|
compressionLevel: number;
|
|
9
17
|
coreProperties: CoreProperties;
|
|
10
18
|
extendedProperties: ExtendedProperties;
|
|
11
19
|
customProperties: CustomProperty[];
|
|
20
|
+
vbaProject?: VbaProject;
|
|
21
|
+
isTemplate: boolean;
|
|
12
22
|
private _readResult?;
|
|
13
23
|
private _dirtySheets;
|
|
14
24
|
markDirty(sheetIndexOrName: number | string): void;
|
|
@@ -20,18 +30,48 @@ export declare class Workbook {
|
|
|
20
30
|
getSheet(name: string): Worksheet | undefined;
|
|
21
31
|
getSheetByIndex(idx: number): Worksheet | undefined;
|
|
22
32
|
getSheetNames(): string[];
|
|
33
|
+
getSheets(): readonly Worksheet[];
|
|
23
34
|
removeSheet(name: string): this;
|
|
35
|
+
addChartSheet(name: string, chart: import('./types.js').Chart): Worksheet;
|
|
36
|
+
addDialogSheet(name: string): Worksheet;
|
|
37
|
+
copySheet(sourceName: string, newName: string): Worksheet;
|
|
38
|
+
private _customTableStyles;
|
|
39
|
+
registerTableStyle(name: string, def: {
|
|
40
|
+
headerRow?: import('./types.js').CellStyle;
|
|
41
|
+
dataRow1?: import('./types.js').CellStyle;
|
|
42
|
+
dataRow2?: import('./types.js').CellStyle;
|
|
43
|
+
totalRow?: import('./types.js').CellStyle;
|
|
44
|
+
}): this;
|
|
24
45
|
addNamedRange(nr: NamedRange): this;
|
|
46
|
+
getNamedRanges(): readonly NamedRange[];
|
|
47
|
+
getNamedRange(name: string): NamedRange | undefined;
|
|
48
|
+
removeNamedRange(name: string): this;
|
|
49
|
+
addConnection(conn: Connection): this;
|
|
50
|
+
getConnections(): readonly Connection[];
|
|
51
|
+
getConnection(name: string): Connection | undefined;
|
|
52
|
+
removeConnection(name: string): this;
|
|
53
|
+
getPowerQueries(): readonly PowerQuery[];
|
|
54
|
+
getPowerQuery(name: string): PowerQuery | undefined;
|
|
25
55
|
getCustomProperty(name: string): CustomProperty | undefined;
|
|
26
56
|
setCustomProperty(name: string, value: CustomProperty['value']): this;
|
|
27
57
|
removeCustomProperty(name: string): this;
|
|
58
|
+
addExternalLink(link: ExternalLink): this;
|
|
59
|
+
getExternalLinks(): readonly ExternalLink[];
|
|
60
|
+
registerPivotStyle(style: CustomPivotStyle): this;
|
|
61
|
+
addPivotSlicer(slicer: PivotSlicer): this;
|
|
62
|
+
getPivotSlicers(): readonly PivotSlicer[];
|
|
28
63
|
build(): Promise<Uint8Array>;
|
|
29
64
|
private _buildPatched;
|
|
30
65
|
private _buildFresh;
|
|
66
|
+
private _headingPairs;
|
|
31
67
|
private _syncLegacyProperties;
|
|
68
|
+
private _ensureVbaSheetModules;
|
|
32
69
|
private _patchWorkbookXml;
|
|
70
|
+
private _definedNamesXml;
|
|
71
|
+
private _connectionsXml;
|
|
33
72
|
private _buildWorkbookRels;
|
|
34
73
|
private _relsToXml;
|
|
74
|
+
private _buildThemeXml;
|
|
35
75
|
private _buildRootRels;
|
|
36
76
|
private _patchContentTypes;
|
|
37
77
|
buildBase64(): Promise<string>;
|