从HTML导出带有样式格式的XLS时出现AlaSql错误

时间:2018-05-01 09:06:40

标签: angularjs xlsx alasql

Alasql似乎非常有助于从JS导出XLS文件,也很容易。 但缺乏良好的教程或者我没有找到一个。

在直接从HTML导出XLS期间,它工作正常,但我无法在此过程中添加一些单元格格式。

我试过了 -

$scope.exportExcel = function() {
        // WORKS FINE
        /* alasql('SELECT * INTO XLSX("myinquires.xlsx", {headers:true}) \
                    FROM HTML("#MyInquires", {headers:true})');*/

       // produces error        
       alasql('SELECT * INTO XLSX("myinquires.xlsx", {headers:true,column:{width:300}}) \
                    FROM HTML("#MyInquires", {headers:true})');
}

从Object而不是HTML导出时,相同的样式工作正常。

这两段代码 - http://plnkr.co/edit/bZsFYkaKIvN26XmpbqCy?p=preview

1 个答案:

答案 0 :(得分:1)

我在代码下方使用格式化我的 Excel ,希望这会有所帮助,

<form th:action="@{/user/add}" method="POST" th:object="${user}" style="width: 70%;">

    <div class="form-group">
        <label for="inputName" class="text-uppercase font-weight-bold">Name</label>
        <input type="text" class="form-control" id="inputName" th:field="*{name}" autocomplete="off">
    </div>

    <div class="form-group">
        <label for="inputSurname" class="text-uppercase font-weight-bold">Surname</label>
        <input type="text" class="form-control" id="inputSurname" th:field="*{surname}" autocomplete="off">
    </div>

    <div class="form-group">
        <label for="inputEmail" class="text-uppercase font-weight-bold">Email</label>
        <input type="email" class="form-control" id="inputEmail" th:field="*{email}" autocomplete="off">
    </div>

    <div class="form-group">
        <label for="inputBirthdate" class="text-uppercase font-weight-bold">Birthdate</label>
        <input type="date" class="form-control" id="inputBirthdate" th:field="*{birthdate}" autocomplete="off">
    </div>

    <div class="form-group mb-5">
        <label for="inputGender" class="text-uppercase font-weight-bold">Gender</label>
        <select type="date" class="form-control" id="inputGender" th:field="*{gender}">
            <option th:value="other">Other</option>
            <option th:value="male">Male</option>
            <option th:value="female">Female</option>
        </select>
    </div>

    <div class="form-group">
        <label for="inputUsername" class="text-uppercase font-weight-bold">Username</label>
        <input type="text" class="form-control" id="inputUsername" th:field="*{username}" autocomplete="off">
    </div>

    <div class="form-group">
        <label for="inputPassword" class="text-uppercase font-weight-bold">Password</label>
        <input type="password" class="form-control" id="inputPassword" th:field="*{password}" autocomplete="off">
    </div>

    <button type="submit" class="btn btn-primary w-100">
        Add User
    </button>
</form>