clarketm / TableExport

The simple, easy-to-implement library to export HTML tables to xlsx, xls, csv, and txt files.
https://tableexport.travismclarke.com/
Apache License 2.0
888 stars 289 forks source link

Formatting #153

Closed RayXia95 closed 6 years ago

RayXia95 commented 6 years ago

This is a pretty solid library!

However, when I am exporting to excel, the cell automatically formats my string, e.x. 'Hello World 2018-3' to 3/1/2018 and I lose the data of 'Hello World' when the sheet actually downloads. Is this intend? Could there be an API to customize the format of the cell before download.

Best, Ray

stgogm commented 6 years ago

I believe this is what you're looking for https://tableexport.v3.travismclarke.com/examples/cell-data-types.html

clarketm commented 6 years ago

@RayXia95 - TableExport attempts to intelligently coerce cell types based on their contents using a customizable typeConfig which contains a predicate function (per type) to determine which cell formatting to apply.

The easiest way to force a specific type is to apply a type class:

type classname
string tableexport-string
number tableexport-number
boolean tableexport-boolean
date tableexport-date

e.g.

<table>
        ...
        <td class="tableexport-string">Hello World 2018-3</td>
        ...
</table>