export etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
export etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

1 Ekim 2012 Pazartesi

Sharepoint 2010 Export all the solutions (wsp files)

Hi,

If you d like to get all the solutions (wsp files) from a sharepoint server and save them into a location, you just need the below code:

Open the Power Shell as Admin, type:


Add-PSSnapin Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue 
## setup our output directory 
$dirName = "d:\exports\ExportedSolutions
Write-Host Exporting solutions to $dirName 
 foreach ($solution in Get-SPSolution) 
 { 
 $id = $Solution.SolutionID 
 $title = $Solution.Name 
 $filename = $Solution.SolutionFile.Name 
 Write-Host "Exporting ‘$title’ to …\$filename" -nonewline 
 try 
 $solution.SolutionFile.SaveAs("$dirName\$filename")
 Write-Host " – done" -foreground green 
 } 
 catch 
 {
 Write-Host " – error : $_" -foreground red 
 }
 }

You can change the output location as you want, it would save all the solutions.

Great time saver !

Cheers

PS: Sorry I forgot to give the source, but you can google it though.

22 Mart 2012 Perşembe

Creating excel by code

Hi,

Sometimes you might need to create an export of a table as an excel file.
Of course there are thousands of tools for that but if you d like to do it manually, here is the code you need:

Sorry I have got the code from one of my collegues, I can not share the source link.


Response.Clear();
            Response.AddHeader("content-disposition", "attachment;filename=Export" + DateTime.Now.ToString("yyyy_MM_dd") + ".xls");
            Response.Charset = "";
            // If you want the option to open the Excel file without saving than
            // comment out the line below
            //Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = "application/vnd.xls";
            System.IO.StringWriter stringWrite = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter htmlWrite =
            new HtmlTextWriter(stringWrite);
Table tbl = //Create your table in here !


tbl.RenderControl(htmlWrite);

//These both line are needed if you like to format the cells as text and number
            string style = @"<style>.text{mso-number-format:\@;text-align:left;};.Nums{mso-number-format:0\.00;};.unwrap{wrap:false}</style>";
            Response.Write(style);

            Response.Write(stringWrite);
            //Response.Write(stringWrite.ToString().Replace(".", ","));
            Response.End();


While you were creating the table you d like to render as excel, you can give the format as below:
row.Cells[0].Attributes.Add("class", "text");
row.Cells[1].Attributes.Add("class", "Nums");

"text" and "Nums" classes should be set after you have rendered your control. (Comments can be found on the first code fragment)

1 Şubat 2012 Çarşamba

Sharepoint 2010 - Granular Backup (site, list import & export)

Export

Go to Central Administration - Backup and Restore - Granular Backup - Export a site or list

Select the site collection - site and list, (depending on your export scope)

Give a export filename
Select export version and press Start Export.

Wait until the process is over.


Import:
Get the path of the .cmp file that you ve exported.

Open the Sharepoint 2010 Management Shell as Administrator

Type
Import-SPWeb <siteUrl> –Path <fullpath of the .cmp file>

Sample:
Import-SPWeb http://tristk004dvp:17691 –Path D:\imports\ExpenseSite.cmp


Note:
If you export-import the files between servers you can use a shared location to keep things simpler.