var flexGrid = new wijmo.grid.FlexGrid('#FlexGrid');
flexGrid.itemsSource = createData(5);
flexGrid.columns[2].width = 150;
flexGrid.itemFormatter = function (panel, r, c, cell) {
if (panel.cellType == wijmo.grid.CellType.Cell) {
if (r == 1) {
if (c == 1) {
var cellData = flexGrid.getCellData(r, c);
cell.innerHTML = wijmo.Globalize.formatDate(cellData, 'yy-MM-dd');
}
else if (c == 2) {
var cellData = flexGrid.getCellData(r, c);
cell.innerHTML = wijmo.Globalize.formatNumber(cellData, 'c');
}
}
}
}
function btn_click() {
wijmo.grid.xlsx.FlexGridXlsxConverter.save(
flexGrid,
{
formatItem: function (args) {
var p = args.panel,
col = args.col,
row = args.row,
xlsxCell = args.xlsxCell;
if (p.cellType == wijmo.grid.CellType.Cell) {
if (p.columns[col].binding == 'id') {
xlsxCell.style.hAlign = wijmo.xlsx.HAlign.Center;
xlsxCell.style.vAlign = wijmo.xlsx.VAlign.Center;
} else if (p.columns[col].binding == 'date') {
xlsxCell.style.format = 'yyyy年MM月dd日';
} else if (p.columns[col].binding == 'amount') {
if (xlsxCell.value) {
if (row == 2) {
xlsxCell.style.format = '0.00%';
}
if (row >= 3) {
xlsxCell.style.format = '\xA5#,##0;\xA5-#,##0';
}
}
}
}
}
},
'FlexGrid.xlsx');
}
function createData(count) {
var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','),
data = [];
for (var i = 0; i < count; i++) {
data.push({
id: i + 1,
date: new Date(2014, i % 12, i % 28),
amount: Math.random() * 10000,
});
}
return data;
}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。