export CSV or LOG file to excel using powershell

May 30, 2013 at 15:34:42
Specs: Windows 7
Hello to all,
I would simply export the data column in my csv or log and create a chart , but I can not figure out how to export
some help?
I have tried using get-content but i don't think is correct

# <---- Start Code --------------------------------------->
$ xl = New-Object-ComObject Excel.Application
# Show Excel
$ xl.visible = $ true
$ xl.DisplayAlerts = $ False
# Open a workbook
$ wb = $ xl.workbooks.add ()
# Create Worksheets
$ ws = $ wb.Worksheets.Item (1) # Opens and 3 empty Excel Worksheets
get-content 'C: \ MINING \ tottempi.log' |% {$ ws.Cells.Item ($ _, 1) = $ _} # adds some dat
ws.range $ range = $ ("a $ {} xrow: $ yrow h") # sets the date range we want to chart
# Create and assign the chart to a variable
# $ ch = $ xl.charts.add () # This will open a new sheet
$ ch = $ ws.shapes.addChart (). chart # This will put the chart in the selected WorkSheet
$ ch.chartType = 51
$ ch.setSourceData ($ range)
$ RngToCover = $ ws.Range ("D5: J19") # This is where we want the chart
$ ChtOb = $ ch.Parent # This selects the current Chart
$ ChtOb.Top = $ RngToCover.Top # This moves it up to row 5
ChtOb.Left $ = $ # and RngToCover.Left to column D
$ ChtOb.Height = $ RngToCover.Height # resize This sets the height of your chart to Rows 5-19
$ ChtOb.Width = $ RngToCover.Width # This sets the width to resize Columns D - J
# <------------- End Code --------------------------------- ----->

############################
This is the input from csv or log file

15,951,535
3,052
1,055
420
66
29
13
20


See More: export CSV or LOG file to excel using powershell

Report •

#1
Report •

#2
June 3, 2013 at 14:43:19
Question: Why not just open the CSV file in Excel?

How To Ask Questions The Smart Way


Report •

#3
June 4, 2013 at 09:06:05
mmm no, I want to automatically generate a graph..

Report •

Related Solutions

#4
June 4, 2013 at 09:39:02
Yes. Have your script tell Excel to open it, and then have your script tell Excel to generate a graph.

EDIT:
Have a look at Workbooks.OpenText

How To Ask Questions The Smart Way


Report •

Ask Question