Toon posts:

PowerShell/Excel

Pagina: 1
Acties:
  • 443 views

Vraag


Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
Goede morgen
Ik vond je hier met:

Title TK: Powershell, Excel and Internationalisation

Bedankt! :)

Hier is het script:
cls

$excel = new-object -comobject Excel.Application
$workbooks = $excel.Workbooks.Add()
$worksheets = $workbooks.worksheets
$worksheet = $worksheets.Item(1)
$worksheet.Name = “Name of Worksheet”

$excel.Visible = $True

# ????
$xlHairline = 1
$xlThin = 2
$xlThick = 4
$xlMedium = -4138

# Microsoft.Office.Interop.Excel.XlBordersIndex
$xlDiagonalDown = 5
$xlDiagonalUp = 6
$xlEdgeLeft = 7
$xlEdgeTop = 8
$xlEdgeBottom = 9
$xlEdgeRight = 10
$xlInsideVertical = 11
$xlInsideHorizontal = 12

# Microsoft.Office.Interop.Excel.XlLineStyle
$xlContinuous = 1
$xlDashDot = 4
$xlDashDotDot = 5
$xlSlantDashDot = 13
$xlLineStyleNone = -4142
$xlDouble = -4119
$xlDot = -4118
$xlDash = -4115

# color index
$xlColorIndexBlue = 5

$worksheet.Cells.Item(1,1) = “This is CELL A1:C3”
$worksheet.Cells.Item(1,1).Font.Bold = $True
$worksheet.Cells.Item(1,1).Font.Size = 22
$worksheet.Cells.Item(1,1).HorizontalAlignment = -4108
$worksheet.Cells.Item(1,1).VerticalAlignment = -4108
$worksheet.Range("a1:c1").MergeCells = $true

$worksheet.Cells.Item(3,4) = “This is CELL D3:E3 {Range/Merge}”
$worksheet.Cells.Item(3,4).Font.Italic = $True
$worksheet.Cells.Item(3,4).Font.Size = 14
$worksheet.Cells.Item(3,4).HorizontalAlignment = -4108 # $xlLeft, $xlRight
$worksheet.Cells.Item(3,4).VerticalAlignment = -4108 # $xlTop, $xlBottom
$worksheet.Cells.Item(3,4).ColumnWidth = 30
$worksheet.Cells.Item(3,4).Borders.Color = 1
$worksheet.Cells.Item(3,4).Borders.Weight = 2
$worksheet.Cells.Item(3,4).Interior.ColorIndex = 37
$worksheet.Range("d3:e3").MergeCells = $true

$worksheet.Cells.Item(4,4) = “This is CELL D4 [Parameter non]”

# Title TK: Powershell, Excel and Internationalisation

# "C#"
$worksheet.Cells.Item(10,1) = “Border Right thin”
$excel.Range("C10").Borders.item($xlEdgeRight).LineStyle = $xlContinuous

$worksheet.Cells.Item(11,1) = “Border Left thin”
$worksheet.Range("c11:c11").Borders.item($xlEdgeleft).LineStyle = $xlContinuous

$worksheet.Cells.Item(12,1) = “Bor. Left/Right med.”
$worksheet.Range("c12:c12").Borders.item($xlEdgeRight).LineStyle = $xlContinuous
$worksheet.Range("c12:c12").Borders.item($xlEdgeRight).Weight = $xlMedium
$worksheet.Range("c12:c12").Borders.item($xlEdgeRight).Color = 2

$worksheet.Range("c12:c12").Borders.item($xlEdgeleft).LineStyle = $xlContinuous
$worksheet.Range("c12:c12").Borders.item($xlEdgeleft).Weight = $xlMedium
$worksheet.Range("c12:c12").Borders.item($xlEdgeleft).Color = 2

$worksheet.Cells.Item(13,1) = “Bor. Diagonal Down”
$worksheet.Range("d13").Borders.item($xlDiagonalDown).LineStyle = $xlContinuous
$worksheet.Range("d13").Borders.item($xlDiagonalDown).Weight = $xlMedium
$worksheet.Range("d13").Borders.item($xlDiagonalDown).Color = 2

$worksheet.Cells.Item(14,1) = “Bor. Diagonal Up”
$worksheet.Range("d14").Borders.item($xlDiagonalUp).LineStyle = $xlContinuous
$worksheet.Range("d14").Borders.item($xlDiagonalUp).Weight = $xlMedium
$worksheet.Range("d14").Borders.item($xlDiagonalUp).Color = 2

$worksheet.Cells.Item(15,1) = “EntireColumn.AutoFit()”

$worksheet.Cells.Item(16,1) = “You can Add any Graphic also. [..(\.(°.°)./)..]”
$worksheet.Cells.Item(17,1) = “I hope this Stuff can Help you. @r”

$worksheet.columns.item("A:F").EntireColumn.AutoFit() | Out-Null

$xlsxPath = 'C:\…haar file naam….. .xlsx'

# $range | get-member
$workbooks.SaveAs($xlsxPath) | Out-Null
$excel.quit()

Alle reacties


Acties:
  • 0 Henk 'm!

  • Hydra
  • Registratie: September 2000
  • Laatst online: 13:59
Euh, was het je bedoeling de auteur van die blogpost een DM te sturen ofzo?

https://niels.nu


Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
Hey,

Alsjeblieft, ik ben op zoek naar / heb hulp nodig.
Ik kan niet verder komen.
Dank u wel

Arnold

Acties:
  • 0 Henk 'm!

  • Dirk
  • Registratie: November 2004
  • Laatst online: 17:55

Dirk

Coördinator frontpagemoderatie
:w

All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.


Dit topic is gesloten.