Posts

Showing posts from September, 2013

Export data from SharePoint Silverlight application to Excel using REST API

This demo will show how to export data from SharePoint Silverlight application to Excel template or excel sheet. Steps: 1.        Create REST API application using MVC4 architecture (URL based navigation). 2.        Integrate URL directly in Silverlight hyperlink control in XAML. Step: Create one MVC4 application using visual studio 2010 frame work. Create one ExportController.cs class file under   Controller   folder in mvc4 project. This class will work as a API application between SharePoint Silverlight and REST API. Create one more ExportRepository.cs file under DataLayer folder. Add one more folder to the solution name as GenerateExcel folder add class file in this folder. File name is ExportToExcel.cs ExportController.cs [ HttpGet ]         [ ActionName ( "SharedDocuments" )]         public HttpResponseMessage Sha...

Get data from sql table using c#

        protected void btnGetData_Click(object sender, EventArgs e)         {             string ConnectionString = "server=*********; uid=*****; pwd=*****; database=*********";            try            {                DataTable dataTable = new DataTable();                SqlConnection conn = new SqlConnection(ConnectionString);                SqlCommand cmd = new SqlCommand("select * from Hyperlinks", conn);                conn.Open();                SqlDataAdapter da = new SqlDataAdapter(cmd);                da.Fill(dataTable);                int i = 0;    ...

Get folder names using share point client object model.

Add the Dll reference "Microsoft.SharePoint.Client.dll" and  "Microsoft.SharePoint.Client.RunTime.dll" to the project. name space reference "using SP = Microsoft.SharePoint.Client;" using  (SP. ClientContext  ctx =  new  SP. ClientContext (ProjectURL))             {                 SP. Web  web = ctx.Web;                 ctx.Load(web);                 SP. List  docList = web.Lists.GetByTitle( "Shared Documents" );                 ctx.Load(docList.RootFolder.Folders);                 SP. FolderCollection  colle...

Export data from sharepoint silverlight text controls to existing Excel sheet template.

String FILE_FILTER = "Excel Files(*.xls)|*.xls"; OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = FILE_FILTER; if (openFileDialog.ShowDialog() == true) { System.IO.FileStream fileStream = openFileDialog.File.OpenRead(); byte[] textBytes = new byte[fileStream.Length]; fileStream.Read(textBytes, 0, textBytes.Length); Workbook workbook = Workbook.Open(fileStream); Worksheet worksheet = workbook.Worksheets[0]; worksheet.Cells[0, 0].Value = ("Datum"); worksheet.Cells[0, 1].Value = ("Avdelning"); worksheet.Cells[0, 2].Value = ("Allvarlighetsgraden"); worksheet.Cells[0, 3].Value = ("Raport"); workbook.Worksheets.Add(worksheet); workbook.Save(fileStream); }