Formatting CSV cell to be Category on Excel from table

Hi,

I was just wondering if its possible to set the column type to be a specific data type after exporting the dataset from a table?

I am aware that we can set the Column type prior to downloading the data as a CSV file as such below

However, I realized that upon opening the CSV file, the formatting disappears as shown below.

I have tried processing the data to ensure that they're numerical and I would still get the same result. I also had a look at the state of the parsed data and it doesn't seem like there would be any control in terms of setting a specific data type for a CSV column.

Currently, I am thinking of exporting an external library on CDN and creating a CSV on my own rather than utilizing Retool's utils / download file button from the table.

I am looking for any other ideas or recommendation in terms of approaching this. Note this is more of a niche requirement for me for sending this file as an API request.

Hey @ericcheong!

I'm not sure there's a way to encode types into a CSV by nature of the file type itself. The program you're using might be able to infer column types but it will be passed as text. Have you had success importing other CSVs in a way that retains their column types?

Otherwise, a number of other people have used libraries like xlsx (SheetJS) to build richer exports, but it can take some extra coding. See, for instance, this example of someone using it to export dates.

Okay, so utilizing an external library is the only option here then. Was wondering if I was missing any parameters when trying to create an Excel file so thought I'd ask.

Thank you for the swift response - I will have a look at the library!