Ziv-Barber / officegen

Standalone Office Open XML files (Microsoft Office 2007 and later) generator for Word (docx), PowerPoint (pptx) and Excell (xlsx) in javascript. The output is a stream.
MIT License
2.63k stars 472 forks source link

XLSX Date support #30

Open lagomarsino opened 10 years ago

lagomarsino commented 10 years ago

Using the two dimensional array, dates are written as zero values:

var fs = require('fs');
var officegen = require('officegen');
var xlsx = officegen ( 'xlsx' );

xlsx.on ( 'finalize', function ( written ) {
            console.log ( 'Finish to create an Excel file.\nTotal bytes created: ' + written + '\n' );
        });

xlsx.on ( 'error', function ( err ) {
            console.log ( err );
        });

sheet = xlsx.makeNewSheet ();
sheet.name = 'Excel Test';

// The direct option - two-dimensional array:
sheet.data[0] = [];
sheet.data[0][0] = new Date();

var out = fs.createWriteStream ( 'out.xlsx' );

out.on ( 'error', function ( err ) {
    console.log ( err );
});

xlsx.generate ( out );
CodersBrothers commented 9 years ago

+1, or some feature to set type of cells. For example if you put 02/16/2015 now not it's readed as date.

Clome commented 2 months ago

@lagomarsino, this is random but any way to contact you?