0

A simple question about fprintf function.

I made a a program that reads lines from a text file which hold values such as

INFO 2013-12-17 11:59:24,549 Thread-3 2032 CommonMMC.request_hardware_state() - Common 1 State = PASS (warn=False,fail=False)
INFO 2013-12-17 11:59:25,081 Thread-3 2032 CommonMMC.request_hardware_state() - Common 1 State = PASS (warn=False,fail=False)
INFO 2013-12-17 11:59:25,549 Thread-3 2032 CommonMMC.request_hardware_state() - Common 1 State = WARN (warn=False,fail=False)
INFO 2013-12-17 11:59:26,081 Thread-3 2032 CommonMMC.request_hardware_state() - Common 1 State = FAIL (warn=False,fail=False)

It then checks for the state change in each line and prints it out respectively onto a .csv file. The .csv file should look like this

XCBU02   PM671   17-DEC-2013     10:30:56    Common 2    State   WARNING

XCBU02   PM671   17-DEC-2013     10:30:56    Common 2    State   PASS

It is all working fine and it prints out correctly.

the printf function is as such :-

fprintf(readCSV_fp, "%s, %s, %s, %s, %s, %d, %s, %s", XCBU, Test_ID, Date, Time, Comm, Num, State, State_Change);

all the Variables are defined as CStrings except for Num which is an int.

My question is, is there a way to print out State_Change onto the .csv file but have it BOLD or Emphasized or even have the cell that it is being printed on in the .csv file to be highlighted?

If yes, how do I manage it? and if its no, is there any other method where I can achieve this?

Thanks.

1 Answers1

1

.CSV file format is a simple text file and it does not support any formatting.

There are many other text formats that allow setting font, background/foreground color, etc.

One of them is Excel Open XML. I believe it will work with Microsoft Excel only... Initial question was mentioning MFC. I think mentioning Excel in the answer is appropriate.

Kirill Kobelev
  • 10,252
  • 6
  • 30
  • 51
  • Is Open XML easy to use? My go-to format has been SYLK. See http://stackoverflow.com/a/137473/5987 – Mark Ransom Jan 23 '14 at 04:17
  • They have a .NET library that has reasonable interface. I used it myself and it works fine. It provides only C# interface. You can research, maybe something is available for C++ also. You can also write small C# samples of what you want and look at what is generated. After that your can generate the same stuffs with C++. – Kirill Kobelev Jan 23 '14 at 06:21