Powershellscript to import excel

 

http://podlisk.wordpress.com/2011/11/20/import-excel-spreadsheet-into-powershell/
How to Import Excel spreadsheet into PowerShell
20 11 2011
In most of the cases, it will be more than sufficient to use very well-known PowerShell command – Import-Csv.
But… there is always a “but”… For every manipulation with every Excel (.XLS, .XLSX) spreadsheet, first you will have to export its content to .CSV. This is minimal requirement. After it, every manipulation with the original file, will cause you to export the file again and again. Finally, what would you do with the Unicode characters? While exporting to .CSV, these characters will be probably lost.
Bottom line, the function presented below – Import-Excel – will help you to load the native Excel spreadsheet directly to array of PowerShell objects. This function, loaded into PowerShell, could be used pretty straight-forward with the syntax described:
Import-Excel [-FileName]:Path [-WorksheetName:"Name"] [-DisplayProgress:$true|$false]
-FileName – path to the Excel file. Since the code uses Excel Com-object, any format supported by local installation of Excel is compatible
-WorksheetName – name of the spreadsheet to load. If not name declared, the first one will be loaded
-DisplayProgress – switch $true or $false to display or not the progress of the load process
The function returns array of objects, where each property name, represented by first row of the Excel spreadsheet.
Finally, the code with few examples right after:
function Import-Excel
{
  param (
    [string]$FileName,
    [string]$WorksheetName,
    [bool]$DisplayProgress = $true
  )

  if ($FileName -eq "") {
    throw "Please provide path to the Excel file"
    Exit
  }
  if (-not (Test-Path $FileName)) {
    throw "Path '$FileName' does not exist."
    exit
  }
  $FileName = Resolve-Path $FileName
  $excel = New-Object -com "Excel.Application"
  $excel.Visible = $false
  $workbook = $excel.workbooks.open($FileName)
  if (-not $WorksheetName) {
    Write-Warning "Defaulting to the first worksheet in workbook."
    $sheet = $workbook.ActiveSheet
  } else {
    $sheet = $workbook.Sheets.Item($WorksheetName)
  }
 
  if (-not $sheet)
  {
    throw "Unable to open worksheet $WorksheetName"
    exit
  }
 
  $sheetName = $sheet.Name
  $columns = $sheet.UsedRange.Columns.Count
  $lines = $sheet.UsedRange.Rows.Count
 
  Write-Warning "Worksheet $sheetName contains $columns columns and $lines lines of data"
 
  $fields = @()
 
  for ($column = 1; $column -le $columns; $column ++) {
    $fieldName = $sheet.Cells.Item.Invoke(1, $column).Value2
    if ($fieldName -eq $null) {
      $fieldName = "Column" + $column.ToString()
    }
    $fields += $fieldName
  }
 
  $line = 2
 
 
  for ($line = 2; $line -le $lines; $line ++) {
    $values = New-Object object[] $columns
    for ($column = 1; $column -le $columns; $column++) {
      $values[$column - 1] = $sheet.Cells.Item.Invoke($line, $column).Value2
    } 
 
    $row = New-Object psobject
    $fields | foreach-object -begin {$i = 0} -process {
      $row | Add-Member -MemberType noteproperty -Name $fields[$i] -Value $values[$i]; $i++
    }
    $row
    $percents = [math]::round((($line/$lines) * 100), 0)
    if ($DisplayProgress) {
      Write-Progress -Activity:"Importing from Excel file $FileName" -Status:"Imported $line of total $lines lines ($percents%)" -PercentComplete:$percents
    }
  }
  $workbook.Close()
  $excel.Quit()
}
Usage examples:
[PS] C:\>$reportLines = Import-Excel C:\Document\my-report.xls
- will import the content of the first spreadsheet from the file, found at “C:\Document\my-report.xls” into $reportLines variable
[PS] C:\>$users = Import-Excel C:\Document\users.xlsx -WorksheetName:"HQ"
- will import the content of the first “HQ” spreadsheet from the “C:\Document\users.xlsx” file into $users variable
I hope this will be helpful. Enjoy the code! Any comments are more than welcome.

Bulk File Uploads to SharePoint shown as Checked Out in WSS 3.0 and MOSS 2007


Issue: You are uploading multiple documents to your SharePoint libraries via the built in multiple document upload capability or through an explorer view. After uploading these files you notice that all these recently uploaded files are marked as checked out and you must manually click "Check in" on each document. This is time consuming and you want to avoid the issue with future uploads.
Background: This situation is related to a versioning setting in your document library.
Suggested Resolution: For the library in question where you are having this issue, do the following:
Navigate to the library then go to > Settings > Document Library Settings



Next click on Versioning Settings

Next Change your settings to require No Versioning, do not require documents to be checked out and then finally click OK to finish


OR --- FOLLOW THIS

Well, there is a simple solution for this: "Site Content and Structure"
Go to Site Actions-> Site Settings -> Under Site administration, you'll see the option "Site Content and Structure"
You can also go to this page by appending the text as shown in following URL:
htp://YourSite/sites/_layouts/sitemanager.aspx
Now in this, navigate to the document library from left side -> and now in main view, select all the documents which you want to check in.
Click on "Actions" from the top and say "Check in" 
Isn't it is simple.!

User group service info path 2010 error Error ID 5566

Error occured Accessing Data Source Error ID 5566

Error while trying to connect to a Web Service - Infopath Form Services


Go to the particular Group which one you are trying to access from infopath form
in Group  setting make the group read by every one.. will solve the issue


How To: Check if a user is part of a SharePoint group in InfoPath

http://www.projectpoint.at/?p=97









Once that is done, close the form and navigate to the location where you exported your form to. Open the file named “GetUserCollectionFromGroup1.xsd“. This file defines the XML schema. Open the file in a text or XML editor. The following steps can be found in Ian’s blog. Thanks again!
Right under this code within the file:
1
<s:import namespace="http://www.w3.org/2001/XMLSchema"></s:import>
insert the following snippet:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<s:complexType name="GetUserCollectionFromGroupType">
 <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="Users">
   <s:complexType>
    <s:sequence>
     <s:element maxOccurs="unbounded" name="User" >
      <s:complexType>
       <s:attribute name="Notes" type="s:string"></s:attribute>
       <s:attribute name="Name" type="s:string"></s:attribute>
       <s:attribute name="IsSiteAdmin" type="s:string"></s:attribute>
       <s:attribute name="Sid" type="s:string"></s:attribute>
       <s:attribute name="ID" type="s:string"></s:attribute>
       <s:attribute name="LoginName" type="s:string"></s:attribute>
       <s:attribute name="Email" type="s:string"></s:attribute>
       <s:attribute name="IsDomainGroup" type="s:string"></s:attribute>
      </s:complexType>
     </s:element>
    </s:sequence>
    </s:complexType>
  </s:element>
 </s:sequence></s:complexType>
Now locate the following piece of code within your file:
1
2
3
4
5
6
7
<s:element name="GetUserCollectionFromGroup">
  <s:complexType> 
    <s:sequence> 
      <s:element minOccurs="0" maxOccurs="1" name="groupName" type="s:string"></s:element>
    </s:sequence> 
  </s:complexType> 
</s:element>
and replace it with this:
1
2
3
4
5
6
7
8
<!--<s:element name="GetUserCollectionFromGroup">  <s:complexType>     <s:sequence>       <s:element minOccurs="0" maxOccurs="1" name="groupName" type="s:string"></s:element>    </s:sequence>   </s:complexType> </s:element>--><s:element name="GetUserCollectionFromGroup" type="tns:GetUserCollectionFromGroupType" />
We are almost there J Now save the file and open the manifest.xsf by right clicking it and select Design.
If you have a look at your GetUserCollectionFromGroup data source and its fields, you will notice that it has changed

sharepoint development training 2010 ,Sharepoint info path

Sharepoint info path development , sharepoint designer workflow please contact me for free service.
on free service basis i can train you sharepoint 2010 . if u r intrested pls contact me
9945264323
cheraideva

Hide ribbon controls items for non admin users in sharepoint 2010 ribbon


<Sharepoint:SPSecurityTrimmedControl runat="server" Permissions="ManageLists">
 add the above code beofre ribbon div  in master page
   <div id="s4-ribbonrow" class="s4-pr s4-ribbonrowhidetitle" style="width:1250px">
......
------
----------------

and end the code like this
</div>
 </SharePoint:SPSecurityTrimmedControl>

 
enjoy...
Only site action able to see.

How to hide viewall site contetn from site action menu in sharepoint 2010



In the default master page (v4.master) the Quicklaunch All Site Content link can be found around line 573 and is included in the PlaceHolderQuickLaunchBottomV4 UIVersionedContent control. Here’s what it looks like by default:

 
 
573<SharePoint:ClusteredSPLinkButton
574    id="idNavLinkViewAllV4"
575    runat="server"
576    PermissionsString="ViewFormPages"
577    NavigateUrl="~site/_layouts/viewlsts.aspx"
578    ImageClass="s4-specialNavIcon"
579    ImageUrl="/_layouts/images/fgimg.png"
580    ImageWidth=16
581    ImageHeight=16
582    OffsetX=0
583    OffsetY=0
584    Text="<%$Resources:wss,quiklnch_allcontent_short%>"
585    accesskey="<%$Resources:wss,quiklnch_allcontent_AK%>"/>

So all we have to do is change line 576 to read PermissionsString=”ManageWeb” and save.

Hiding the Site Actions Link

The Site Actions menu is just as easy to edit. The View All Site Content link can be found around line 137 inside the SiteActions FeatureMenuTemplate control. Here’s what it looks like by default:

 
 
137<SharePoint:MenuItemTemplate runat="server" id="MenuItem_ViewAllSiteContents"
138    Text="<%$Resources:wss,quiklnch_allcontent%>"
139    Description="<%$Resources:wss,siteactions_allcontentdescription%>"
140    ImageUrl="/_layouts/images/allcontent32.png"
141    MenuGroupId="300"
142    Sequence="302"
143    UseShortId="true"
144    ClientOnClickNavigateUrl="~site/_layouts/viewlsts.aspx"
145    PermissionsString="ViewFormPages"
146    PermissionMode="Any" />

Again, just change line 145 to PermissionsString=”ManageWeb” and save.
That’s it! Here’s what the same Team Site now looks like to a user with Read permission:


SPFX - HTTPClient - Curd Operations - SharePoint list.

  Create solution in the name of SpfxCrud. ISpfxCrudProps.ts export interface ISpfxCrudProps {   description : string ;     context : an...