Skip to content

Instantly share code, notes, and snippets.

@aykutyaman
Created August 28, 2018 14:18
Show Gist options
  • Save aykutyaman/ea34040dfdf6cf33f8c96a01490d98f2 to your computer and use it in GitHub Desktop.
Save aykutyaman/ea34040dfdf6cf33f8c96a01490d98f2 to your computer and use it in GitHub Desktop.
const express = require('express');
const xl = require('excel4node');
const app = express();
const makeReport = (request, response) => {
const wb = new xl.Workbook();
const ws = wb.addWorksheet('Ödenmiş Mesai Raporu');
// Create a reusable style
var titleStyle = wb.createStyle({
font: {
bold: true,
color: '#000000',
size: 13,
},
alignment: {
wrapText: false,
horizontal: 'center',
}
});
var nameStyle = wb.createStyle({
font: {
size: 12,
color: '#66ccff',
},
alignment: {
vertical: 'center',
},
});
var numberStyle = wb.createStyle({
font: {
size: 12,
},
alignment: {
horizontal: 'center',
vertical: 'center',
}
});
// ad soyad kolonu ve imza kolonlari biraz genis olsun
ws.column(1).setWidth(35);
ws.column(14).setWidth(25);
// aylar
ws.cell(1, 1).string('Personel Adı').style(titleStyle);
ws.cell(1, 2).string('Ocak').style(titleStyle);
ws.cell(1, 3).string('Şubat').style(titleStyle);
ws.cell(1, 4).string('Mart').style(titleStyle);
ws.cell(1, 5).string('Nisan').style(titleStyle);
ws.cell(1, 6).string('Mayıs').style(titleStyle);
ws.cell(1, 7).string('Haziran').style(titleStyle);
ws.cell(1, 8).string('Temmuz').style(titleStyle);
ws.cell(1, 9).string('Ağustos').style(titleStyle);
ws.cell(1, 10).string('Eylül').style(titleStyle);
ws.cell(1, 11).string('Ekim').style(titleStyle);
ws.cell(1, 12).string('Kasım').style(titleStyle);
ws.cell(1, 13).string('Aralık').style(titleStyle);
ws.cell(1, 14).string('İmza').style(titleStyle);
// personel 1
ws.cell(2, 1).string('Adalet Parlakdemir').style(nameStyle);
ws.cell(2, 2).number(50).style(numberStyle);
ws.cell(2, 3).number(40).style(numberStyle);
ws.cell(2, 4).number(22).style(numberStyle);
ws.cell(2, 5).number(36).style(numberStyle);
ws.cell(2, 6).number(50).style(numberStyle);
ws.cell(2, 7).number(40).style(numberStyle);
ws.cell(2, 8).number(22).style(numberStyle);
ws.cell(2, 9).number(36).style(numberStyle);
ws.cell(2, 10).number(50).style(numberStyle);
ws.cell(2, 11).number(40).style(numberStyle);
ws.cell(2, 12).number(22).style(numberStyle);
ws.cell(2, 13).number(36).style(numberStyle);
ws.row(2).setHeight(30);
// personel 2
ws.cell(3, 1).string('Adem Durmaz').style(nameStyle);
ws.cell(3, 2).number(30).style(numberStyle);
ws.cell(3, 3).number(40).style(numberStyle);
ws.cell(3, 4).number(12).style(numberStyle);
ws.cell(3, 5).number(46).style(numberStyle);
ws.cell(3, 6).number(50).style(numberStyle);
ws.cell(3, 7).number(30).style(numberStyle);
ws.cell(3, 8).number(12).style(numberStyle);
ws.cell(3, 9).number(38).style(numberStyle);
ws.cell(3, 10).number(59).style(numberStyle);
ws.cell(3, 11).number(39).style(numberStyle);
ws.cell(3, 12).number(22).style(numberStyle);
ws.cell(3, 13).number(36).style(numberStyle);
ws.row(3).setHeight(30);
wb.write('foo.xlsx', response);
};
app.get('/', (request, response) => {
makeReport(request, response);
});
app.listen(3000, () => console.log('server listening on port: 3000'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment