Skip to content

Instantly share code, notes, and snippets.

View Mavlarn's full-sized avatar

Mavlarn Mavlarn

  • Vantiq
View GitHub Profile
@Mavlarn
Mavlarn / about-me
Created March 11, 2014 16:09
about-me
# RESUME
## Personal Information
----
Name: Mavlarn. Tuohuti (买乌拉江)
Birthday: 1980
Gender: male
Phone: 13810957617
Email: mavlarn@163.com mavlarn@gmail.com
Nation: China
// just wrap 'filesizejs.com' as filter.
module
.filter('FileSize', function () {
return function (arg, descriptor) {
var si = {
bits : ["B", "kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb"],
bytes : ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
};

Export HTML table to Excel in AngularJS

myApp.factory('Excel',function($window){
		var uri='data:application/vnd.ms-excel;base64,',
			template='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>',
			base64=function(s){return $window.btoa(unescape(encodeURIComponent(s)));},
			format=function(s,c){return s.replace(/{(\w+)}/g,function(m,p){return c[p];})};
		return {