SheetXL - v0.8.0-beta.9+sites.210.e2d420901
    Preparing search index...

    Interface Registry

    interface Registry {
        registerEncryption(encryption: EncryptionType): Promise<void>;
        registerReadFormat(format: ReadFormatType): Promise<void>;
        registerWriteFormat(format: WriteFormatType): Promise<void>;
    }
    Index
    • Registers an encryption envelope, or replaces an existing one with the same key.

      Parameters

      • encryption: EncryptionType

        The envelope definition (detect / decode / encode).

      Returns Promise<void>

      An envelope is format-independent — it wraps whatever bytes a format handler produced — so registering one enables password support for every registered format at once. See IWorkbookIO.EncryptionType.

      registry.registerEncryption({
      key: 'offcrypto',
      description: 'Office Document Encryption',
      detect: (bytes) => isEncryptedOfficeContainer(bytes),
      decode: (bytes, password) => decryptOffCrypto(bytes, password),
      encode: (bytes, password) => encryptOffCrypto(bytes, password)
      });
    • Registers a new read format type or replaces an existing one.

      Parameters

      • format: ReadFormatType

        The format type definition containing decoder logic.

      Returns Promise<void>

      Use this to add support for new workbook encoding formats (not source types). If a format with the same key already exists, it will be replaced.

      This allows you to:

      • Add custom format types (e.g., proprietary formats)
      • Override built-in format handlers
      • Extend format support for your application

      The registered format will work with all source types automatically.

      // Register a custom XML-based format
      workbookIO.registerReadFormat({
      key: 'custom-xml',
      description: 'Custom XML Workbook Format',
      mimeType: 'application/x-custom-workbook+xml',
      exts: ['.cwb', '.cxml'],
      tags: ['xml', 'custom'],
      handler: async (buffer, options) => {
      // Decode buffer into IWorkbook
      const xmlString = new TextDecoder().decode(buffer);
      return parseCustomXML(xmlString);
      }
      });

      // Now any source type can use this format
      await workbookIO.read({ source: 'data.cwb' }); // Auto-detected
      await workbookIO.read({ source: fileObject, format: 'custom-xml' });
    • Registers a new write format type or replaces an existing one.

      Parameters

      • format: WriteFormatType

        The format type definition containing encoder logic.

      Returns Promise<void>

      Use this to add support for new workbook encoding formats (not source types). If a format with the same key already exists, it will be replaced.

      This allows you to:

      • Add custom format types (e.g., proprietary formats)
      • Override built-in format handlers
      • Extend format support for your application

      The registered format can then be written to any source type (File, ArrayBuffer, etc.).

      // Register a custom JSON-based format
      workbookIO.registerWriteFormat({
      key: 'custom-json',
      description: 'Custom JSON Workbook Format',
      mimeType: 'application/json',
      ext: '.cjson',
      tags: ['json', 'custom'],
      handler: async (workbook, options) => {
      // Encode workbook into ArrayBuffer
      const jsonString = JSON.stringify(customSerialize(workbook));
      return new TextEncoder().encode(jsonString).buffer;
      }
      });

      // Use with any write method
      await workbookIO.write(workbook, { fileName: 'report.cjson' });
      const buffer = await workbookIO.writeArrayBuffer(workbook, { format: 'custom-json' });