Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11508

Exporting Data Automatically to CSV from a list

$
0
0

We have a SharePoint Custom List which is used for job recording and billing.  We would like to automatically export the list to a CSV as follows:

  • List will be exported to a CSV daily if a checkbox is ticked "Ready for Invoice"
  • Certain Columns are exported in a specific order to the file
  • Items in the list have a checkbox ticked by the script marking them as "Invoiced" so they are NOT exported again.

So far I have had partial success exporting some basic data using the following:

$MyWeb = Get-SPWeb "http://companyweb"
$MyList = $MyWeb.Lists["Allocation A&E & Events"]
$exportlist = @()
$Mylist.Items | foreach {
$obj = New-Object PSObject -Property @{
 "Invoice Amount" = $_["Invoice Amount"]                  
        "Callsign" = $_["Title"]
 "Client" = $_["Client"]
 "Date" = $_["Start Date"]
 "Unique Job Ref" = $_["ID"]
}
$exportlist += $obj
$exportlist | Export-Csv -path 'C:\Temp\MediForce-Invoice.csv'
}

The exported data looks like this:

#TYPE System.Management.Automation.PSCustomObject
"Date","Callsign","Client","Invoice Amount","Unique Job Ref"
"07/06/2013 12:00:00","MF10","clientname","float;#0","36"

  • I would like to remove the quotes around the values
  • Invoice Amount shows float;#0 and not just the currency value
  • Fields are not sorted according to the script

Any help would be greatly appreciated.

James


Viewing all articles
Browse latest Browse all 11508

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>