Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View SheetJSDev's full-sized avatar
📗
Getting Sheet Done

Eric P Sheets SheetJSDev

📗
Getting Sheet Done
View GitHub Profile
#!/bin/bash
set -o pipefail
UZIPVER=$(date "+0.%Y%m%d.0")
# Remove and re-clone
rm -rf UZIP.js
git clone https://github.com/photopea/UZIP.js/
cd UZIP.js
# Generate package.json
@SheetJSDev
SheetJSDev / main.js
Created August 22, 2014 14:40
XLSX writing custom date formats
/* this sample was run in nodejs */
var XLSX = require('xlsx');
/* build up a very simple workbook */
var wb = {
SSF: XLSX.SSF.get_table(),
SheetNames: ["Sheet1"],
Sheets: {
Sheet1: {
'!ref': 'A1:A1',
@SheetJSDev
SheetJSDev / xlsx2socialcalc.js
Created August 3, 2014 17:43
xlsx2socialcalc
/* xlsx2socialcalc.js (C) 2014 SheetJS -- http://sheetjs.com */
/* License: Apache 2.0 */
/* vim: set ts=2: */
var sheet_to_socialcalc = (function() {
var header = [
"socialcalc:version:1.5",
"MIME-Version: 1.0",
"Content-Type: multipart/mixed; boundary=SocialCalcSpreadsheetControlSave"
].join("\n");
@notatestuser
notatestuser / gist:30ba66ebdeb69a48bea7
Created May 23, 2014 13:39
sheet_to_row_object_array_with_column_index_props for js-xls(x)
var XLS = { utils: {
// originally https://github.com/SheetJS/js-xls/blob/4076850087785b76e6814213877eea99a8390be5/xls.js#L5135
sheet_to_row_object_array_with_column_index_props:
function(sheet, opts) {
var val, row, r, hdr = {}, isempty, R, C, v;
var out = [];
opts = opts || {};
if(!sheet || !sheet["!ref"]) return out;
r = xls_utils.decode_range(sheet["!ref"]);
for(R=r.s.r, C = r.s.c; C <= r.e.c; ++C) {
/* require XLSX */
var XLSX = require('XLSX')
function datenum(v, date1904) {
if(date1904) v+=1462;
var epoch = Date.parse(v);
return (epoch - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000);
}
function sheet_from_array_of_arrays(data, opts) {
(function(undefined) {
'use strict';
// Check if dependecies are available.
if (typeof XLSX === 'undefined') {
console.log('xlsx.js is required. Get it from https://github.com/SheetJS/js-xlsx');
return;
}
if (typeof _ === 'undefined') {
console.log('Lodash.js is required. Get it from http://lodash.com/');
var xlsx = require('xlsx');
var _ = require('underscore');
var file = 'test.xlsx';
function parsePos(x) { // "AB" => 26*1 + 1*2 => 28
var str = x.toUpperCase();
var ret = 0;
for(var i=0,len=str.length; i<len; i++) {
ret += Math.pow(26,(len - i -1)) * (str.charCodeAt(i)-64);
@mjackson
mjackson / color-conversion-algorithms.js
Last active April 14, 2024 08:46
RGB, HSV, and HSL color conversion algorithms in JavaScript
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation