Putting Excel formatting and/or formulas into CSV file

  • Thread starter Frank D. Nicodem, Jr.
  • Start date
F

Frank D. Nicodem, Jr.

Is it possible to include any Excel formula or formatting information in a
CSV file?

I have numerous applications (typically written in SQL) that generate files
that I then use within Excel. To keep things simple, I've always just
generated the files as text files, in CSV format, so that they can be easily
imported into Excel.

However, I have two requirements that I would like to accomplish, and didn't
know if either were possible. The first is that I'd like to include some
basic formatting of the cells, when they are imported. I know I can do that
manually, when I import the file, but I was hoping to be able to do some
very minimal things (e.g., bolding text) by including some kind of
information within the CSV file itself. Thus, when the CSV file was
imported into Excel, those formatting features would already be in place.

The second requirement would be to find out if there is a way to include any
simple formulas in a CSV file. That might be, for example, to generate a
Sum in a particular cell, or perhaps even a percentage, or some other
calculation based on other information in the file. Is there any way at all
to "embed" formulas within a CSV file, such that they will be evaluated when
the CSV file is imported into Excel? Or is that purely something that
requires generating a complete XLS file?

BTW, if a CSV file is incapable of doing what I need, but anyone knows of
ANOTHER way to accomplish this, I'd be happy to know. Again, the
fundamental issue would be if there is any way to generate a file from an
external program (such as VB, SQL, or other application) which could be
imported into Excel, and already include formulas, or basic cell formatting.
 
D

Dave Peterson

CSV files are plain text--they don't sort formatting.

If you store your formulas as text (and you're careful with your addressing),
excel will see them as formulas (if they start with an equal sign).

But I wouldn't do either of those.

I'd store my data as .txt

Then create a macro that opens that text file, applies the formatting, inserts
the formulas, and does other stuff (page setup, filters, sorts, pivottables,
etc).

Then use that macro whenever I wanted to bring in that .txt file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top