prince antony
prince antony

Reputation: 19

How to bold the particular row in CSV using PowerShell?

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.

Upvotes: 0

Views: 1318

Answers (2)

Modro
Modro

Reputation: 436

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.

Upvotes: 1

Scepticalist
Scepticalist

Reputation: 3923

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.

Upvotes: 1

Related Questions