Skip to content

Wrong stream finish event - when committing workbook stream #198

Closed
@junajan

Description

@junajan

ExcelJs does not finish properly when using stream buffer like this:

@options.workbookOpts = {
#   filename: 'tmp/test.xlsx',
#   stream: @outputStream,
    useStyles: true,
    useSharedStrings: true
};

@workbook = new Excel.stream.xlsx.WorkbookWriter @options.workbookOpts
@worksheet = @workbook.addWorksheet('WSName')
@workbook.stream.pipe(@outputStream)

## add some rows

@workbook.commit()
.then (res) =>
 console.log("END")

On this line https://github.com/guyonroche/exceljs/blob/master/lib/stream/xlsx/workbook-writer.js#L320 you are listening for finish event which is correct for writeStreams (based on node.js doc: https://nodejs.org/api/stream.html#stream_event_finish)

But here in the StreamBuf class you are emitting end event instead:
https://github.com/guyonroche/exceljs/blob/master/lib/utils/stream-buf.js#L287

Possible solutions are:

  1. Emit finish event instead. (Or emit both end and finish events?)
    PR: Fire finish event instead of end event on write stream #199

  2. Don't listen for events on StreamBuf but on zipStream instead.
    PR: Listen for finish event on zip stream instead of middle stream #200

Sideinfo: end event is on readStreams instead.

Workaround: is to use stream: --writeStream-- option instead of piping (in my code it is commented out).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy