.net barcode reader sdk Creating Site Collections Based on an Excel Spreadsheet in Visual Studio .NET

Creator Quick Response Code in Visual Studio .NET Creating Site Collections Based on an Excel Spreadsheet

Creating Site Collections Based on an Excel Spreadsheet
QR Decoder In VS .NET
Using Barcode Control SDK for .NET Control to generate, create, read, scan barcode image in .NET applications.
Creating Quick Response Code In .NET
Using Barcode maker for .NET Control to generate, create QR-Code image in .NET framework applications.
In this scenario, our IT department has created a Microsoft Excel 2010 spreadsheet containing a list of all the currently running projects Each project requires a new site collection The Excel spreadsheet has the following column headings: Project Name Project Description Project Manager Project Manager Logon Name Department Cost Center Project Type Before looking into how to create all the site collections, let s see how we can work with Excel 2010 using Windows PowerShell
Recognize QR Code In .NET
Using Barcode reader for .NET framework Control to read, scan read, scan image in .NET framework applications.
Paint Bar Code In VS .NET
Using Barcode creation for .NET Control to generate, create barcode image in Visual Studio .NET applications.
Working with Excel Spreadsheets
Barcode Scanner In Visual Studio .NET
Using Barcode recognizer for Visual Studio .NET Control to read, scan read, scan image in Visual Studio .NET applications.
QR Code Creation In C#
Using Barcode generator for .NET Control to generate, create QR Code image in .NET framework applications.
In this example, we will use the Connection object in ADO ADODBConnection is used to read, edit, and update databases such as Microsoft Access, and it can also be used to read data in Excel spreadsheets We can create an instance of the ADODB Connection object using the New-Object cmdlet
Printing QR Code JIS X 0510 In VS .NET
Using Barcode encoder for ASP.NET Control to generate, create Denso QR Bar Code image in ASP.NET applications.
Denso QR Bar Code Generation In VB.NET
Using Barcode encoder for VS .NET Control to generate, create QR Code image in VS .NET applications.
PS > $excelConnection= New-Object -ComObject "ADODBConnection"
Code128 Creation In .NET Framework
Using Barcode creation for Visual Studio .NET Control to generate, create Code 128B image in .NET framework applications.
Drawing Bar Code In Visual Studio .NET
Using Barcode drawer for Visual Studio .NET Control to generate, create bar code image in .NET framework applications.
11:
Drawing EAN13 In .NET Framework
Using Barcode maker for .NET Control to generate, create EAN13 image in .NET applications.
MSI Plessey Generator In Visual Studio .NET
Using Barcode creator for .NET framework Control to generate, create MSI Plessey image in .NET framework applications.
Working with Site Collections
Drawing 1D Barcode In C#
Using Barcode creation for Visual Studio .NET Control to generate, create 1D image in .NET applications.
European Article Number 13 Recognizer In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
Next, we open a connection to the Excel spreadsheet using the Open method supported by the Connection object When creating a connection string to an Excel spreadsheet, we use the OLE DB provider and specify the path to the Excel file
Printing USS Code 128 In VB.NET
Using Barcode generator for .NET framework Control to generate, create Code 128 image in .NET framework applications.
UPC-A Supplement 2 Recognizer In .NET
Using Barcode decoder for .NET Control to read, scan read, scan image in .NET framework applications.
PS PS >> >> >> > $file = "C:\Documents\projectsxlsx" > $excelConnectionOpen( "Provider=MicrosoftACEOLEDB120;Data Source=" + "$file;Extended Properties=Excel 120;" )
Decoding USS Code 128 In Java
Using Barcode reader for Java Control to read, scan read, scan image in Java applications.
Matrix Barcode Maker In Visual Basic .NET
Using Barcode maker for VS .NET Control to generate, create Matrix 2D Barcode image in Visual Studio .NET applications.
After we have established a connection to the Excel spreadsheet, we can execute a query that retrieves the values from the spreadsheet This example demonstrates how we pass the query to the Execute method:
Making Bar Code In None
Using Barcode generation for Online Control to generate, create bar code image in Online applications.
Scan EAN / UCC - 13 In Visual C#.NET
Using Barcode scanner for Visual Studio .NET Control to read, scan read, scan image in Visual Studio .NET applications.
PS > $strQuery = "Select * from [Sheet1$]" PS > $objRecordSet = $excelConnectionExecute($strQuery)
Notice how we use Sheet1$ in the query, which is the name of the sheet from which we want to retrieve the data By default, Excel spreadsheets are named Sheet1, Sheet2, Sheet3, and so on If you have a worksheet with a custom name, use that name in the query Before looping through the fields and retrieving the values, we should get the field names since we will use them later We can retrieve the field names from the Fields property Here, we use the Select-Object cmdlet to retrieve the fields:
PS > $fields = $objRecordSetFields | Select-Object -Property Name
Next, we move to the first record in the recordset using the MoveFirst method The first record represents the first row in the Excel spreadsheet
PS > $objRecordSetMoveFirst()
Finally, we loop through the records and retrieve the values from the Excel spreadsheet
PS > do { >> $obj = New-Object -TypeName PSObject >> $fields | ForEach-Object { >> $obj | >> Add-Member -MemberType NoteProperty -Name $_Name ` >> -Value $objRecordSetFieldsItem($_Name)Value >> } >> $obj >> $objRecordSetMoveNext() >>} until ($objRecordSetEOF)
PowerShell for Microsoft SharePoint 2010 Administrators
We use a do until loop to go through each record in the recordset We start the loop by creating a custom object, which we will use to store the output We then loop through each field using the ForEach-Object cmdlet and use the current field s name as input to the Item parameterized property to retrieve the field value Using the field name and field value with the Add-Member cmdlet, we are able to store the information in a custom object After the record s fields and values are stored in the custom object, the object is returned Finally, we use the MoveNext method to move on to the next row and repeat the procedure The loop continues until the EOF (end of file) property evaluates to true After the loop completes, we tidy up our objects using the Close method
PS > $objRecordSetClose() PS > $excelConnectionClose()
The following shows the complete Get-Excel function that we can use to read information from an Excel spreadsheet
function Get-Excel([string]$File) { $excelConnection = New-Object -ComObject "ADODBConnection" $excelConnectionOpen( "Provider=MicrosoftACEOLEDB120;Data Source=" + "$File;Extended Properties=Excel 120;" ) $strQuery ="Select * from [Sheet1$]" $objRecordSet = $excelConnectionExecute($strQuery) $fields = $objRecordSetFields | Select-Object -Property Name $objRecordSetMoveFirst() do { $obj = New-Object -TypeName PSObject $fields | ForEach-Object { $obj | Add-Member -MemberType NoteProperty -Name $_Name ` -Value $objRecordSetFieldsItem($_Name)Value } $obj $objRecordSetMoveNext() } until ($objRecordSetEOF) $objRecordSetClose() $excelConnectionClose() }
11:
Copyright © OnBarcode.com . All rights reserved.