• Stars
    star
    188
  • Rank 205,563 (Top 5 %)
  • Language
    JavaScript
  • Created over 11 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

SimpleExcel.js - WIP client-side script to parse / convert / write XML / CSV / TSV / HTML / JSON / etc formats.

SimpleExcel.js

Client-side script to easily parse / convert / write any Microsoft Excel XLSX / XML / CSV / TSV / HTML / JSON / etc formats. As for server-side solution you might want to check SimpleExcelPHP

Example

<!doctype html>
<html>
    <head>
        <script type="text/javascript" src="simple-excel.js"></script>
    </head>
    <body>
        <input type="file" id="fileInput" /><br/>
        <input type="button" id="fileExport" />
        <script type="text/javascript">

            // read a CSV file
            var csvParser = new SimpleExcel.Parser.CSV();
            var fileInput = document.getElementById('fileInput');
            // parse when file loaded, then print the result to console
            fileInput.addEventListener('change', function (e) {            
                var file = e.target.files[0];
                csvParser.loadFile(file, function () {
                    console.log(csvParser.getSheet()); // print!
                });
            });

            // write an XLSX file            
            var xlsxWriter = new SimpleExcel.Writer.XLSX();
            var xlsxSheet = new SimpleExcel.Sheet();
            var Cell = SimpleExcel.Cell;
            xlsxSheet.setRecord([
                [new Cell('ID', 'TEXT'), new Cell('Nama', 'TEXT'), new Cell('Kode Wilayah', 'TEXT')],
                [new Cell(1, 'NUMBER'), new Cell('Kab. Bogor', 'TEXT'), new Cell(1, 'NUMBER')],
                [new Cell(2, 'NUMBER'), new Cell('Kab. Cianjur', 'TEXT'), new Cell(1, 'NUMBER')],
                [new Cell(3, 'NUMBER'), new Cell('Kab. Sukabumi', 'TEXT'), new Cell(1, 'NUMBER')],
                [new Cell(4, 'NUMBER'), new Cell('Kab. Tasikmalaya', 'TEXT'), new Cell(2, 'NUMBER')]
            ]);
            xlsxWriter.insertSheet(xlsxSheet);
            // export when button clicked
            document.getElementById('fileExport').addEventListener('click', function () {            
                xlsxWriter.saveFile(); // pop! ("Save As" dialog appears)
            });

        </script>
    </body>
</html>

License

GPLv2 & MIT License

Copyright © 2013 Faisalman <[email protected]>

More Repositories

1

ua-parser-js

UAParser.js - The Essential Web Development Tool for User-Agent Detection.
JavaScript
9,032
star
2

simple-excel-php

Simplexcel.php - Easily read / parse / convert / write between Microsoft Excel XML / CSV / TSV / HTML / JSON / etc spreadsheet tabular file formats
PHP
559
star
3

flash-cookie-js

FlashCookie.js - JavaScript library to manage persistent cross-browser & cross-domain cookies by utilizing Flash Player plugin
ActionScript
16
star
4

fallr-js

Fallr.js - Fancy, simple, yet elegant message / alert / prompt / dialog / popup / notification / modal box jQuery plugin
JavaScript
13
star
5

ua-client-hints-js

UAClientHints.js - Parse & serialize user-agent client hints (UA-CH) HTTP headers
TypeScript
10
star
6

sms-pdu-js

SMSPDU.js - SMS PDU library written in JavaScript
JavaScript
10
star
7

docklr-css

Give your site a macOS-like Dock menu & stacks using pure CSS3 (no JS needed!)
CSS
9
star
8

explr-js

Explr.js jQuery plugin - Create a "Windows Explorer"-like Tree structure
JavaScript
8
star
9

age-calc-cs

AgeCalc.cs - C# age calculation library: calculate relative time (years, months, days) since birthday.
C#
5
star
10

sticklr-js

Sticklr.js - Sticky side panel jQuery plugin
CSS
4
star
11

phone-identifier-java

PhoneIdentifier.java - Indonesian phone number identifier
Java
3
star
12

time-cs

Time.cs - C# extension methods for DateTime to calculate relative time and age
C#
2
star
13

jQuery-LiveTweet

A jQuery plugin to fetch tweets from Twitter
JavaScript
1
star
14

querystring-cs

QueryString.cs - Extended C# QueryString Library
C#
1
star
15

gpu-detect-js

Detect & Extract GPU info from the Browser
TypeScript
1
star
16

ua-unfreeze-js

Unreduced, freeze-free version of your user-agent
TypeScript
1
star