0

I want to bold a particular row (for ex: row 1) present in CSV file but I cannot able to bold the row. I imported a CSV file in a variable and used System.Windows.Form.Label method to bold the row in CSV file. I am unable to figure out what went wrong.

$c = Get-Content ".\Documents\test\test.csv"
$LabelComputer = New-Object System.Windows.Forms.Label
$LabelComputer.Text = $c | Select-Object -First 1
$LabelComputer.Font = [System.Drawing.Font]::new("Microsoft Sans Serif", 12, [System.Drawing.FontStyle]::Bold)
$LabelComputer.Text | Add-Content ".\Documents\test\new.csv"
Number | Message | Mobile
1      | hello   | 1***6
2      |  hi     | 2**7

Expected: I expect the row 1 (1 hello 1**6) to be bold.

Output: Row1 is not getting bold.

2
  • See @Scepticalist answer. If you are displaying the csv in a Form it should be possible to show one line of text bolded, but then you need to edit your question and give us the whole code for building that form and displaying the CSV in there you have. Commented Aug 21, 2019 at 7:21
  • The formatting you create applies to the Label object. It is not preserved when you write the text of the Label object back to a file. Not to mention that CSV doesn't support formatting anyway. Commented Aug 21, 2019 at 8:27

2 Answers 2

1

CSV doesn't support this - you can do it in Excel but it won't save the formatting.

If you need this kind of formatting, use xls or similar.

Sign up to request clarification or add additional context in comments.

Comments

1

There's no way to do that in CSV. You could all caps the output, or you could use another format that supports text styles.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.