javascript - 使用 ALASQL (AngularJS) 格式化导出的 Excel

标签 javascript angularjs export-to-excel alasql

首先是对alasql项目的贡献者的高度赞扬。将我的 JSON 数据导出到 excel 文件对我有很大帮助。但对于接下来的步骤,我需要一些有关格式化 excel 文件的帮助。

是否可以定义具有自动宽度的单元格?我需要为一列着色。

我在另一个thread 看到过一个帖子,但这在我的示例中不起作用。

这是我的代码:

var opts = {
        headers: true,
        column: {
            style: {
                Font: {
                    Bold: "1"
                }
            }
        },
        rows: {
            1: {
                style: {
                    Font: {
                        Color: "#FF0077"
                    }
                }
            }
        },
        cells: {
            1: {
                1: {
                    style: {
                        Font: {
                            Color: "#00FFFF"
                        }
                    }
                }
            }
        }
    };

vm.btnExport = function () {
        alasql('shortcode AS Short_Code, \ ' + 
                'fname AS Fullname, \ ' +
                'INTO XLSX("test.xlsx", ?) FROM ?', [opts, vm.list]);
};

最佳答案

我有个好主意试试这个..

var opts = {
    sheetid : ' Report',
    headers : true,
    style : 'font-size:25px',
    caption : {
        title : 'Report',
    },
    columns : [
        {
            title : "column Name",
            columnid : "key value"
        }
    ],
    rows: {
        //for putting background color in particular column
        0: {
            cell: {
                style: 'font-size:17px;background:#115ea2;color:white;font-weight:bold'
            }
        },
    },
    cells: {
        //if you want to put style in particular cell 
        1: {
            5: {
                style: 'font-size:20px;background:#115ea2 ;color:white;font-weight:bold;text-align:right',
                value: function(value){return value;}
            },
        }
    }
};

vm.btnExport = function () {
        alasql('shortcode AS Short_Code, \ ' + 
                'fname AS Fullname, \ ' +
                'INTO XLSX("test.xlsx", ?) FROM ?', [opts, vm.list]);
};

关于javascript - 使用 ALASQL (AngularJS) 格式化导出的 Excel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36404656/

相关文章:

javascript - 下划线绑定(bind) vs jQuery.proxy vs native 绑定(bind)

javascript - jPlayer 视频无法在 iOs - iPad 和 iPhone 中播放

javascript - AngularJS: "isolate scope"还是 "isolated scope"?

javascript - angular.js 简单函数

javascript - 选择年份的 ng-options 列表并默认查看当前年份

c# - 导出到 Excel 作为 Web API 中的响应

javascript - 根据页面上的选择控件更改jsGrid insertvalue

javascript - jsf在鼠标悬停/移出时装饰dataTable行

asp.net-core - 使用 Asp.net Core 将 DataList 导出到 Excel

java - 如何禁用 Excel 报告中的 "grid line"选项?