8

I have data in a list. One of the views has the data grouped by a column, so I have it looking the way I want.

Requirements for the report:

  • Have a front page with the name of the report, date, etc.
  • Have pages showing the list data
  • Have a final page with a form for users to sign
  • Report can be in Word or PDF format, or potentially even a HTML page that can be printed, as long as the formatting is correct

How can I take this view of the list and generate a report?

I am looking for answers please on how to achieve this both on SharePoint Online and SharePoint on premise (but not necessarily the same solution for both).

  • From where the form on 3rd page coming ? Is it ok if you have this in the excel , instead of page , data will be in the tabs ? like tab 1 -> Name , Tabl 2--> List Data --> tab 3 --> Form ( if source is known) – Bhaskar Dhone Dec 18 '15 at 12:51
  • No that wouldn't be acceptable. I need a report that can be printed that looks professional and has the front and end pages. – Submits Dec 18 '15 at 14:31
  • Do you want these pages in SharePoint itself or can they be anywhere? That is, for SPOnline are you looking for an App or is this running elsewhere and just fetching data from SP? – Prakash Dec 21 '15 at 6:26
  • I would like a method that allows the user to click a button on a SharePoint page (probably somewhere near the list data) which then generates the report. – Submits Dec 21 '15 at 9:02
2
+50

You can use the SPContext object to get the current site/list . Using CSOM You are able to get list items from the object.

-->Once you get all the fields items in the object , after that you can make HTML Format to display the list items as you want.

-->At the end of the , You can Add new html control to fulfill Your requirement "Have a final page with a form for users to sign".

-->You got the generated HTML with necessary data, You can use third party tools like "winnovative" html to pdf converter".

--> You have to pass the generated HTML To "winnovative" and set some Properties of winnovative. You have to Add winnovative assembly to your solution.

Properties like : AutoSizePdfPage,PageHeight,PageWidth.

This is the very Traditional Approach. I hope you can fulfill your requirement with this stuff.

Note : You can impliment it using C# code.So i am sure it's working on Prem but i am not sure about sharepoint online.

Reference : http://www.winnovative-software.com/Help/rtf_to_pdf/html/Properties_T_Winnovative_WnvRtfToPdf_PdfConverter.htm

  • 1
    Thanks, this is a possible solution for on premises, which I'll look into. I also need a solution for SharePoint Online - any ideas? – Submits Dec 18 '15 at 14:33
  • 1
    I will look for SharePoint online for the same. I'll get back to u. . – Dipen Shah Dec 20 '15 at 9:12
  • I don't think we can justify the cost of Winnovate's software license. I don't think this will be an option for us unfortunately. Do you know of any free or cheaper alternatives? – Submits Dec 21 '15 at 8:41
  • 1
    @Submits I had worked with winnovative Aspose Pdf is one alternative of Winnovative [aspose.com]. I am not sure aspose can take html string or not.'itextsharp html to pdf' can take html as a string and convert it to PDF. – Dipen Shah Dec 21 '15 at 8:46
  • In the end this is what I did. Pulled all items using REST, formatting the table how I wanted with HTML, then opened the HTML in a new window so it was perfect for printing. The page breaks were achieved with simple CSS, which allowed me to have my cover page and final page. Thanks for your suggestion. – Submits Dec 25 '15 at 15:08
2

I have done searching on to generate report from share point online.

You can generate report from share point online list item using CSOM.

Using console application you can access all the list item and manipulate as you want.

You have to add "using Microsoft.SharePoint.Client;".

You can get web using below function .

var Test = new Program();
Test.GetWeb(context, web);

function getWeb()
{
     context.Load(context.Web, w => w.ServerRelativeUrl);
     context.ExecuteQuery();
     Console.WriteLine("Connection Established...!!! ");
}

You can use Linq to connect to online sharepoint.

function getList(ClientContext Context, Web web)
{
  ListCollection oList = web.Lists;
  Context.Load(oList, List => List.Include(list => list.Title, list => list.Id));
  Context.ExecuteQuery();
  foreach (List li in oList)
  {
     // Your code to manipulate
  }
}

function ListItem(ClientContext Context, Web web)
{
   List SelectedList = Context.Web.Lists.GetByTitle("**Your List Name**");
   CamlQuery query = CamlQuery.CreateAllItemsQuery(100);
   ListItemCollection listItems = SelectedList.GetItems(query);
   Context.Load(listItems);
   Context.ExecuteQuery();
   Foreach loop on ListItems
   {
     // You html code to generate Report
   }
   // Pass HTml string to third party tool Winnovative.

}

Using Console application you can generate PDF file of your list item in your format with sharepoint online.

--> You have to call console application using Azure timer job or manually.

--> Set your DLL of Console application to the azure machine and set regular time when you want to generate the PDF .

--> This is solution to get data from SharePoint online and generate PDF report on this .

Try it and let me know if you will get any new information regarding it.

  • See my previous comment about the Winnovate software license. Also, I did think about building a HTML string with the list items, but I couldn't figure out how you would insert page breaks to ensure the cover page is the first page of the report and the final page of the report is the table that user's have to sign. Any ideas? – Submits Dec 21 '15 at 8:43
  • Whole Procedure to Generate HTML is depending on Business Logic Only.Step 1: Genrate HTML for first page of the Report. It might be company name and information step 2: fetch properties of list items using for loop and set items value in HTML string one by one. Step 3: Once all the items property is set, Create new HTMl string for last page of report where you want to add table.step 4 : At the end Append all the String in one, and pass it to PDF tool. Note : You have to take care of page height and width – Dipen Shah Dec 21 '15 at 9:06
1
  • system.data does not work on sharepoint-online(Sandboxsolutions)
  • external dll not allowed like itextsharp(not trusted)...

S1-You can Create a webpart(like your page examples) & hide toolbars then fill your data and then Ctrl-P your page save as PDF.

S2-You can use Document Content types and fill your data but I don't know how...(You can't use word automation services on sponline)

  • S1 gives me the list data part of the report, but how do I get a front page for the report and a last page with the form for people to sign? S2 just won't be possible because of the amount of data. – Submits Dec 18 '15 at 14:36
  • S2-I found it... You can use for office document.. Visual Studio =>New Project=>Office/Sharepoint=>Word 2013 Document templates... Create a new project.. by using CSOM code behind then publish it.. Take your file upload your document like list content type... – Ali Can Canbek Dec 21 '15 at 16:08
1

For on premises you could user SQL Server Reporting Services. Here's an example on how to create this: https://www.mssqltips.com/sqlservertip/2068/using-a-sharepoint-list-as-a-data-source-in-sql-server-reporting-services-2008-r2/. You might need to redo the grouping, as I'm not sure SSRS will respect this part of the view. SSRS will generate the report for you in Word, PDF or you can view it in the report viewer.

For SharePoint online, this probably isn't going to work as authentication is an issue. You could sync the list with a local DB and use SSRS. Or you can write you're own custom application and use CSOM to get you're data in stead of SSRS. If you can make it work for SharePoint online, on premises should also work. Only the authentication part is different.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.