2

I'm writing a Powershell script to enforce "General Formatting" of Column AI. This is what I have and it didn't appear to execute.

$worksheet.columns.items('AI').GeneralFormat = $true

What is the right Powershell code for such a task?

General Formatting:

2 Answers 2

4

The clue is in your screenshot; the tooltip specifies this is the "Number Format" setting.

$worksheet.Columns("AI").NumberFormat = "General"

Check out the MSDN page on NumberFormat. Unfortunately it doesn't list the allowed values; this StackOverflow q/a appears to cover that.

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

Comments

3

This works

$Excel01 = New-Object -ComObject Excel.Application
$Excel01.Visible = $True
$Workbook01 = $Excel01.Workbooks.Add()
$Worksheet01 = $Workbook01.Sheets.Item(1)
$Worksheet01.Activate()
$Excel01.Columns.item('d').NumberFormat = "0"

1 Comment

What value does this add over the accepted answer posted a year earlier?

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.