0
votes

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

1 Answers

1
votes

.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.