Code Monkey home page Code Monkey logo

Comments (3)

leaker avatar leaker commented on May 12, 2024

You can use doc.Save to write content as a stream. Here's an example in Go:

package main

import (
    "io"
    "os"

    "github.com/gofika/xlsx"
)

func main() {
    // open file to write
    f, err := os.OpenFile("output.xlsx", os.O_CREATE|os.O_WRONLY, 0644)
    if err != nil {
        panic(err)
    }
    defer f.Close()

    doc := xlsx.NewFile()

    // do something with doc
    // ...

    // write to file or any io.Writer as stream
    doc.Save(f)
}

The core goal of my library is to use memory as much as possible to store file data in order to achieve the highest performance.

xlsx.File does not have a Close function because all modifications to the data are done in memory starting from xlsx.NewFile or xlsx.OpenFile. The document data in memory is written out only when SaveFile or Write is called.

from xlsx.

SharkFourSix avatar SharkFourSix commented on May 12, 2024

So you're saying, using doc.Save will flush the current data out of memory to the file so I can safely call it multiple times? And what happens to the previously constructed rows? I can save to the file every X amount of rows but I'm not sure if the memory will keep growing

from xlsx.

leaker avatar leaker commented on May 12, 2024

doc.Save writes out the document data in memory, but it does not clear the current memory information. It is safe to call doc.Save multiple times. All building actions are done in memory. Even if you save the file every X lines, the memory will still increase as the document data increases.

The purpose of this library's design is to operate xlsx files with the highest performance, and it is not specifically optimized for small devices such as embedded systems. If you are working with an xlsx document larger than 1GB, it is recommended that your hardware memory be larger than 1GB.

from xlsx.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.