├── .gitattributes ├── .gitignore ├── LICENSE.txt ├── README.md ├── nuget ├── CreatePackages.bat └── PublishPackages.bat └── src ├── DoddleReport.AbcPdf ├── DoddleReport.AbcPdf.csproj ├── DoddleReport.AbcPdf.nuspec ├── PDFTable.cs ├── PdfDocument.cs ├── PdfReportWriter.cs ├── Properties │ └── AssemblyInfo.cs ├── packages.config └── web.config.transform ├── DoddleReport.OpenXml ├── DoddleReport.OpenXml.csproj ├── DoddleReport.OpenXml.nuspec ├── ExcelReportWriter.cs ├── Extensions.cs ├── PaperSize.cs ├── Properties │ └── AssemblyInfo.cs ├── packages.config └── web.config.transform ├── DoddleReport.Sample.Web ├── Areas │ └── Reporting │ │ ├── Controllers │ │ └── DoddleController.cs │ │ ├── ReportingAreaRegistration.cs │ │ └── Views │ │ └── Web.config ├── Content │ ├── Site.css │ ├── doddleHtmlReport.png │ ├── doddleTxtReport.png │ ├── doddlepdfreport.png │ └── doddlexlsreport.png ├── Controllers │ ├── AbcPdfController.cs │ ├── DataAnnotationsController.cs │ ├── DoddleController.cs │ ├── DoddleController.cs.pp │ ├── DynamicController.cs │ ├── ExpandoController.cs │ ├── HomeController.cs │ └── TestController.cs ├── DoddleReport.Sample.Mvc.nuspec ├── DoddleReport.Sample.Web.csproj ├── Global.asax ├── Global.asax.cs ├── Helpers │ └── ProductReportHelper.cs ├── Models │ └── DoddleProductRepository.cs ├── Properties │ └── AssemblyInfo.cs ├── Views │ ├── Home │ │ └── Index.aspx │ ├── Shared │ │ ├── Error.aspx │ │ └── Site.Master │ └── Web.config ├── Web.Debug.config ├── Web.Release.config ├── Web.config ├── WebForms │ ├── ProductReport.ashx │ └── ProductReport.ashx.cs └── packages.config ├── DoddleReport.Sample.WinForms ├── DoddleReport.Sample.WinForms.csproj ├── Form1.Designer.cs ├── Form1.cs ├── Form1.resx ├── Program.cs └── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── DoddleReport.Web ├── DoddleReport.Web.csproj ├── DoddleReport.Web.csproj.DotSettings ├── DoddleReport.Web.csproj.ReSharper ├── DoddleReport.Web.nuspec ├── Helpers │ ├── ControllerExtensions.cs │ └── RouteExtensions.cs ├── Properties │ └── AssemblyInfo.cs ├── ReportResult.cs ├── ReportRouteConstraint.cs ├── WebReport.cs └── packages.config ├── DoddleReport.iTextSharp ├── DoddleReport.iTextSharp.csproj ├── DoddleReport.iTextSharp.nuspec ├── PdfReportWriter.cs ├── Properties │ └── AssemblyInfo.cs ├── packages.config └── web.config.transform ├── DoddleReport.sln └── DoddleReport ├── Configuration ├── Config.cs ├── DoddleReportSection.cs ├── StyleElement.cs ├── StyleElementCollection.cs ├── WriterElement.cs └── WriterElementCollection.cs ├── DoddleReport.csproj ├── DoddleReport.csproj.DotSettings ├── DoddleReport.csproj.ReSharper ├── DoddleReport.nuspec ├── Dynamic └── DynamicReportSource.cs ├── Helpers ├── HtmlFormatHelper.cs ├── ReflectionExtensions.cs └── StringExtensions.cs ├── HorizontalAlignment.cs ├── IReportSource.cs ├── IReportWriter.cs ├── Properties └── AssemblyInfo.cs ├── RenderHintsCollection.cs ├── Report.cs ├── ReportBuilder.cs ├── ReportField.cs ├── ReportFieldCollection.cs ├── ReportOrientation.cs ├── ReportRow.cs ├── ReportRowCollection.cs ├── ReportRowEventArgs.cs ├── ReportRowType.cs ├── ReportSources ├── DataTableReportSource.cs └── EnumerableReportSource.cs ├── ReportStyle.cs ├── ReportTextFieldCollection.cs ├── RowField.cs ├── RowFieldCollection.cs ├── RowFieldDataDictionary.cs ├── SharePoint └── SPListReportSource.cs ├── VerticalAlignment.cs ├── Writers ├── DelimitedTextReportWriter.cs ├── ExcelReportWriter.cs └── HtmlReportWriter.cs └── web.config.transform /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | .vs/ 44 | 45 | # Build results 46 | 47 | [Dd]ebug/ 48 | [Rr]elease/ 49 | x64/ 50 | build/ 51 | [Bb]in/ 52 | [Oo]bj/ 53 | 54 | # MSTest test Results 55 | [Tt]est[Rr]esult*/ 56 | [Bb]uild[Ll]og.* 57 | 58 | *_i.c 59 | *_p.c 60 | *.ilk 61 | *.meta 62 | *.obj 63 | *.pch 64 | *.pdb 65 | *.pgc 66 | *.pgd 67 | *.rsp 68 | *.sbr 69 | *.tlb 70 | *.tli 71 | *.tlh 72 | *.tmp 73 | *.tmp_proj 74 | *.log 75 | *.vspscc 76 | *.vssscc 77 | .builds 78 | *.pidb 79 | *.log 80 | *.scc 81 | 82 | # Visual C++ cache files 83 | ipch/ 84 | *.aps 85 | *.ncb 86 | *.opensdf 87 | *.sdf 88 | *.cachefile 89 | 90 | # Visual Studio profiler 91 | *.psess 92 | *.vsp 93 | *.vspx 94 | 95 | # Guidance Automation Toolkit 96 | *.gpState 97 | 98 | # ReSharper is a .NET coding add-in 99 | _ReSharper*/ 100 | *.[Rr]e[Ss]harper 101 | 102 | # TeamCity is a build add-in 103 | _TeamCity* 104 | 105 | # DotCover is a Code Coverage Tool 106 | *.dotCover 107 | 108 | # NCrunch 109 | *.ncrunch* 110 | .*crunch*.local.xml 111 | 112 | # Installshield output folder 113 | [Ee]xpress/ 114 | 115 | # DocProject is a documentation generator add-in 116 | DocProject/buildhelp/ 117 | DocProject/Help/*.HxT 118 | DocProject/Help/*.HxC 119 | DocProject/Help/*.hhc 120 | DocProject/Help/*.hhk 121 | DocProject/Help/*.hhp 122 | DocProject/Help/Html2 123 | DocProject/Help/html 124 | 125 | # Click-Once directory 126 | publish/ 127 | 128 | # Publish Web Output 129 | *.Publish.xml 130 | *.pubxml 131 | *.publishproj 132 | 133 | # NuGet Packages Directory 134 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 135 | packages/ 136 | 137 | # Xamarin 138 | *.userprefs 139 | Components/ 140 | 141 | # Windows Azure Build Output 142 | csx 143 | *.build.csdef 144 | 145 | # Windows Store app package directory 146 | AppPackages/ 147 | 148 | # Others 149 | sql/ 150 | *.Cache 151 | ClientBin/ 152 | [Ss]tyle[Cc]op.* 153 | ~$* 154 | *~ 155 | *.dbmdl 156 | *.[Pp]ublish.xml 157 | *.pfx 158 | *.publishsettings 159 | 160 | # RIA/Silverlight projects 161 | Generated_Code/ 162 | 163 | # Backup & report files from converting an old project file to a newer 164 | # Visual Studio version. Backup files are not needed, because we have git ;-) 165 | _UpgradeReport_Files/ 166 | Backup*/ 167 | UpgradeLog*.XML 168 | UpgradeLog*.htm 169 | 170 | # SQL Server files 171 | App_Data/*.mdf 172 | App_Data/*.ldf 173 | 174 | ############# 175 | ## Windows detritus 176 | ############# 177 | 178 | # Windows image file caches 179 | Thumbs.db 180 | ehthumbs.db 181 | 182 | # Folder config file 183 | Desktop.ini 184 | 185 | # Recycle Bin used on file shares 186 | $RECYCLE.BIN/ 187 | 188 | # Mac crap 189 | .DS_Store 190 | 191 | 192 | ############# 193 | ## Python 194 | ############# 195 | 196 | *.py[cod] 197 | 198 | # Packages 199 | *.egg 200 | *.egg-info 201 | dist/ 202 | build/ 203 | eggs/ 204 | parts/ 205 | var/ 206 | sdist/ 207 | develop-eggs/ 208 | .installed.cfg 209 | 210 | # Installer logs 211 | pip-log.txt 212 | 213 | # Unit test / coverage reports 214 | .coverage 215 | .tox 216 | 217 | #Translations 218 | *.mo 219 | 220 | #Mr Developer 221 | .mr.developer.cfg 222 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Matt Hidinger 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | DoddleReport generates a variety of reports from any IEnumerable datasource. 4 | 5 | Out of the box it can render reports to Excel, PDF, HTML, and CSV – fully extensible of course. I designed the project to provide reporting output over the LINQ queries we had already written for the application, but maybe you can find other uses for it. 6 | 7 | ## New to DoddleReport? 8 | 9 | * Look at the **[Building your first report](https://github.com/matthidinger/DoddleReport/wiki/Building-your-first-report)** page 10 | * If you’re using ASP.NET make sure to check out **[ASP.NET Reporting](https://github.com/matthidinger/DoddleReport/wiki/ASP.NET-Reporting)** section 11 | * Review the ```DoddleReport.Sample.Web``` project in the solution 12 | * Check out the **[Wiki](https://github.com/matthidinger/DoddleReport/wiki/)** for advanced customization and configuration 13 | 14 | # Find it on NuGet 15 | 16 | DoddleReport has been split into multiple packages to support more users’ needs. See their Descriptions within NuGet for more on the differences 17 | 18 | #### Main package 19 | * ```Install-Package DoddleReport``` 20 | 21 | #### ASP.NET integration 22 | * ```Install-Package DoddleReport.Web``` 23 | 24 | #### Additional Report Writers 25 | * ```Install-Package DoddleReport.iTextSharp``` 26 | * ```Install-Package DoddleReport.AbcPdf``` 27 | * ```Install-Package DoddleReport.OpenXml``` 28 | 29 | # Basic Usage 30 | 31 | ```csharp 32 | // Get the data for the report (any IEnumerable will work) 33 | var query = ProductRepository.GetAll(); 34 | 35 | // Create the report and turn our query into a ReportSource 36 | var report = new Report(query.ToReportSource()); 37 | 38 | // Customize the Text Fields report.TextFields.Title = "Products Report"; 39 | report.TextFields.SubTitle = "This is a sample report showing how Doddle Report works"; 40 | report.TextFields.Footer = "Copyright 2016 © The Doddle Project"; 41 | 42 | // Render hints allow you to pass additional hints to the reports as they are being rendered 43 | report.RenderHints.BooleanCheckboxes = true; 44 | 45 | // Customize the data fields report.DataFields["Id"].Hidden = true; 46 | report.DataFields["Price"].DataFormatString = "{0:c}"; 47 | report.DataFields["LastPurchase"].DataFormatString = "{0:d}"; 48 | ``` 49 | 50 | # Live Samples! 51 | 52 | To showcase the functionality take a look at the following sample reports, which are being generated **live in real-time** (notice the data will change every time you open the report) 53 | 54 | ### Excel Report (OpenXML) 55 | 56 | * Creates a native Excel file using OpenXML 57 | * Requires the ```DoddleReport.OpenXml``` package 58 | * Automatic Sticky/Frozen Headers stay at the top when scrolling through the data 59 | * [**See it live!**](http://doddlereport.azurewebsites.net/Doddle/ProductReport.xlsx) 60 | 61 | [![doddlexlsreport](http://download.codeplex.com/download?ProjectName=doddlereport&DownloadId=204393 "doddlexlsreport")](http://download.codeplex.com/download?ProjectName=doddlereport&DownloadId=204392) 62 | 63 | 64 | ### PDF Reports 65 | 66 | #### Using iTextSharp 67 | 68 | * Automatically repeats title and column headers numbers on every page 69 | * Requires the ```DoddleReport.iTextSharp``` package 70 | * [**See it live!**](http://doddlereport.azurewebsites.net/Doddle/productreport.pdf) 71 | 72 | #### Using ABCpdf 73 | 74 | * Automatically repeats title and column headers numbers on every page 75 | * Requires the ```DoddleReport.AbcPdf``` package 76 | * _Requires an_ [_ABCpdf license_](http://www.websupergoo.com/products.htm#pd) 77 | * [**See it live!**](http://doddlereport.azurewebsites.net/AbcPdf/ProductReport.pdf) 78 | 79 | 80 | [![image](http://download.codeplex.com/Download?ProjectName=doddlereport&DownloadId=310428 "image")](http://download.codeplex.com/Download?ProjectName=doddlereport&DownloadId=310427) 81 | 82 | 83 | ### CSV/Delimited 84 | 85 | * Use any kind of delimiter you want 86 | * [**See it live!**](http://doddlereport.azurewebsites.net/Doddle/productreport.txt) 87 | 88 | [![doddleTxtReport](http://download.codeplex.com/download?ProjectName=doddlereport&DownloadId=204395 "doddleTxtReport")](http://download.codeplex.com/download?ProjectName=doddlereport&DownloadId=204394) 89 | 90 | 91 | ### HTML Report 92 | 93 | * Good old HTML report 94 | * [**See it live!**](http://doddlereport.azurewebsites.net/Doddle/productreport.html) 95 | 96 | [![doddleHtmlReport](http://download.codeplex.com/download?ProjectName=doddlereport&DownloadId=204399 "doddleHtmlReport")](http://download.codeplex.com/download?ProjectName=doddlereport&DownloadId=204398) 97 | 98 | -------------------------------------------------------------------------------- /nuget/CreatePackages.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | 4 | @rd /S /Q packages 5 | @mkdir packages 6 | 7 | nuget restore ..\src\DoddleReport.sln 8 | nuget pack ..\src\DoddleReport\DoddleReport.csproj -prop Configuration=Release -Build -Symbols -OutputDirectory .\packages 9 | nuget pack ..\src\DoddleReport.AbcPdf\DoddleReport.AbcPdf.csproj -prop Configuration=Release -Build -Symbols -OutputDirectory .\packages 10 | nuget pack ..\src\DoddleReport.iTextSharp\DoddleReport.iTextSharp.csproj -prop Configuration=Release -Build -Symbols -OutputDirectory .\packages 11 | nuget pack ..\src\DoddleReport.OpenXml\DoddleReport.OpenXml.csproj -prop Configuration=Release -Build -Symbols -OutputDirectory .\packages 12 | nuget pack ..\src\DoddleReport.Web\DoddleReport.Web.csproj -prop Configuration=Release -Build -Symbols -OutputDirectory .\packages 13 | 14 | nuget pack ..\src\DoddleReport.Sample.Web\DoddleReport.Sample.Mvc.nuspec -OutputDirectory .\packages 15 | 16 | -------------------------------------------------------------------------------- /nuget/PublishPackages.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | 4 | call CreatePackages.bat 5 | 6 | pause 7 | 8 | forfiles /p packages /m *.nupkg /c "cmd /c nuget push @path" 9 | -------------------------------------------------------------------------------- /src/DoddleReport.AbcPdf/DoddleReport.AbcPdf.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {355CAFF3-F806-4194-BE54-2F7640463CED} 9 | Library 10 | Properties 11 | DoddleReport.AbcPdf 12 | DoddleReport.AbcPdf 13 | v4.0 14 | 512 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 3.5 26 | 27 | publish\ 28 | true 29 | Disk 30 | false 31 | Foreground 32 | 7 33 | Days 34 | false 35 | false 36 | true 37 | 0 38 | 1.0.0.%2a 39 | false 40 | false 41 | true 42 | 43 | 44 | 45 | 46 | true 47 | full 48 | false 49 | bin\Debug\ 50 | DEBUG;TRACE 51 | prompt 52 | 4 53 | AllRules.ruleset 54 | 55 | 56 | pdbonly 57 | true 58 | bin\Release\ 59 | TRACE 60 | prompt 61 | 4 62 | AllRules.ruleset 63 | bin\Release\DoddleReport.AbcPdf.XML 64 | 65 | 66 | false 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | ..\packages\ABCpdf.9.0.0.5\lib\net20\ABCpdf.dll 75 | True 76 | 77 | 78 | 79 | 3.5 80 | 81 | 82 | 83 | 3.5 84 | 85 | 86 | 3.5 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | False 100 | .NET Framework 3.5 SP1 Client Profile 101 | false 102 | 103 | 104 | False 105 | .NET Framework 3.5 SP1 106 | true 107 | 108 | 109 | False 110 | Windows Installer 3.1 111 | true 112 | 113 | 114 | 115 | 116 | 117 | Designer 118 | 119 | 120 | 121 | 122 | 123 | {F08B2994-4D05-423E-A8FE-7D1E8A63472B} 124 | DoddleReport 125 | 126 | 127 | 128 | 135 | -------------------------------------------------------------------------------- /src/DoddleReport.AbcPdf/DoddleReport.AbcPdf.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | $id$ 7 | $description$ 8 | $author$ 9 | $author$ 10 | https://github.com/matthidinger/DoddleReport 11 | false 12 | doddle.report doddle.reporting doddle reporting pdf excel csv abcpdf 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/DoddleReport.AbcPdf/PDFTable.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthidinger/DoddleReport/d68c344d1b012937c7ff5b9c6e9233d421d1995e/src/DoddleReport.AbcPdf/PDFTable.cs -------------------------------------------------------------------------------- /src/DoddleReport.AbcPdf/PdfDocument.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using WebSupergoo.ABCpdf7; 3 | 4 | namespace DoddleReport.AbcPdf 5 | { 6 | public class PdfDocument : Doc 7 | { 8 | public PdfDocument() 9 | : this(ReportOrientation.Portrait) 10 | { } 11 | 12 | public PdfDocument(ReportOrientation orientation) 13 | { 14 | 15 | this.FontSize = 6; 16 | this.Rect.Inset(5, 5); 17 | this.Orientation = orientation; 18 | } 19 | 20 | private ReportOrientation _orientation; 21 | 22 | public ReportOrientation Orientation 23 | { 24 | get { return _orientation; } 25 | set 26 | { 27 | _orientation = value; 28 | if (value == ReportOrientation.Landscape) 29 | SetLandscape(); 30 | } 31 | } 32 | 33 | public void Write(Stream destination) 34 | { 35 | base.Save(destination); 36 | } 37 | 38 | private void SetLandscape() 39 | { 40 | // apply a rotation transform 41 | double w = this.MediaBox.Width; 42 | double h = this.MediaBox.Height; 43 | double l = this.MediaBox.Left; 44 | double b = this.MediaBox.Bottom; 45 | this.Transform.Rotate(90, l, b); 46 | this.Transform.Translate(w, 0); 47 | 48 | // rotate our rectangle 49 | this.Rect.Width = h; 50 | this.Rect.Height = w; 51 | 52 | int theID = this.GetInfoInt(this.Root, "Pages"); 53 | this.SetInfo(theID, "/Rotate", "90"); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/DoddleReport.AbcPdf/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DoddleReport.AbcPdf")] 9 | [assembly: AssemblyDescription("Adds ABCpdf support to DoddleReport. Requires an ABCpdf license to work properly")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Matt Hidinger")] 12 | [assembly: AssemblyProduct("DoddleReport.AbcPdf")] 13 | [assembly: AssemblyCopyright("Copyright © 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("03fd366c-8b20-4360-9c11-f59ede91f277")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.5.2.0")] 36 | -------------------------------------------------------------------------------- /src/DoddleReport.AbcPdf/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/DoddleReport.AbcPdf/web.config.transform: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/DoddleReport.OpenXml/DoddleReport.OpenXml.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {0646C575-0EA6-4331-809C-10DC000929F3} 9 | Library 10 | Properties 11 | DoddleReport.OpenXml 12 | DoddleReport.OpenXml 13 | v4.0 14 | 512 15 | 16 | 17 | ..\ 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | bin\Release\DoddleReport.OpenXml.XML 36 | 37 | 38 | false 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | False 47 | ..\packages\ClosedXML.0.68.1\lib\net40-client\ClosedXML.dll 48 | 49 | 50 | True 51 | ..\packages\DocumentFormat.OpenXml.1.0\lib\DocumentFormat.OpenXml.dll 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | Designer 71 | 72 | 73 | 74 | 75 | 76 | 77 | {F08B2994-4D05-423E-A8FE-7D1E8A63472B} 78 | DoddleReport 79 | 80 | 81 | 82 | 89 | -------------------------------------------------------------------------------- /src/DoddleReport.OpenXml/DoddleReport.OpenXml.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | $id$ 7 | $description$ 8 | $author$ 9 | $author$ 10 | https://github.com/matthidinger/DoddleReport 11 | false 12 | doddle.report doddle.reporting doddle reporting pdf excel csv openxml 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/DoddleReport.OpenXml/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Windows.Forms; 6 | using ClosedXML.Excel; 7 | 8 | namespace DoddleReport.OpenXml 9 | { 10 | internal static class Extensions 11 | { 12 | #region Declarations 13 | 14 | private static readonly string[] Digits = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; 15 | 16 | #endregion 17 | 18 | #region Methods 19 | 20 | public static void CopyTo(this Stream input, Stream output) 21 | { 22 | var buffer = new byte[32768]; 23 | int read; 24 | while ((read = input.Read(buffer, 0, buffer.Length)) > 0) 25 | { 26 | output.Write(buffer, 0, read); 27 | } 28 | } 29 | 30 | /// 31 | /// Copies the report style to an XL Style. 32 | /// 33 | /// The report style. 34 | /// The xl style. 35 | public static void CopyToXlStyle(this ReportStyle reportStyle, IXLStyle xlStyle) 36 | { 37 | if (reportStyle.BackColor != Color.White) 38 | { 39 | xlStyle.Fill.BackgroundColor = XLColor.FromColor(reportStyle.BackColor); 40 | } 41 | 42 | if (reportStyle.ForeColor != Color.Black) 43 | { 44 | xlStyle.Font.SetFontColor(XLColor.FromColor(reportStyle.ForeColor)); 45 | } 46 | 47 | xlStyle.Font.SetBold(reportStyle.Bold); 48 | xlStyle.Font.SetFontSize(reportStyle.FontSize); 49 | xlStyle.Font.SetItalic(reportStyle.Italic); 50 | xlStyle.Font.SetUnderline(reportStyle.Underline ? XLFontUnderlineValues.Single : XLFontUnderlineValues.None); 51 | xlStyle.Alignment.Horizontal = 52 | reportStyle.HorizontalAlignment == HorizontalAlignment.Center ? XLAlignmentHorizontalValues.Center : 53 | reportStyle.HorizontalAlignment == HorizontalAlignment.Left ? XLAlignmentHorizontalValues.Left : 54 | XLAlignmentHorizontalValues.Right; 55 | xlStyle.Alignment.Vertical = 56 | reportStyle.VerticalAlignment == VerticalAlignment.Bottom ? XLAlignmentVerticalValues.Bottom : 57 | reportStyle.VerticalAlignment == VerticalAlignment.Middle ? XLAlignmentVerticalValues.Center : 58 | XLAlignmentVerticalValues.Top; 59 | xlStyle.Alignment.TextRotation = reportStyle.TextRotation; 60 | } 61 | 62 | /// 63 | /// Pixels to point. 64 | /// 65 | /// The pixels. 66 | /// The font. 67 | /// 68 | /// The value in points. 69 | /// 70 | /// 71 | /// The formula is documented there: http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.column.aspx 72 | /// 73 | public static double PixelsToUnits(this int pixels, IXLFont xlFont) 74 | { 75 | if (pixels < 5) 76 | { 77 | pixels = 5; 78 | } 79 | 80 | var fontSize = (float)xlFont.FontSize; 81 | var font = new Font(xlFont.FontName, fontSize, FontStyle.Regular); 82 | int underscoreWidth = TextRenderer.MeasureText("__", font).Width; 83 | double maxDigitWidth = Digits.Select(d => TextRenderer.MeasureText("_" + d + "_", font).Width - underscoreWidth).Max(); 84 | return Math.Truncate((pixels - 5) / maxDigitWidth * 100 + 0.5) / 100; 85 | } 86 | 87 | #endregion 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/DoddleReport.OpenXml/PaperSize.cs: -------------------------------------------------------------------------------- 1 | namespace DoddleReport.OpenXml 2 | { 3 | public enum PaperSize 4 | { 5 | A2Paper = 0x42, 6 | A3ExtraPaper = 0x3f, 7 | A3ExtraTransversePaper = 0x44, 8 | A3Paper = 8, 9 | A3TransversePaper = 0x43, 10 | A4ExtraPaper = 0x35, 11 | A4Paper = 9, 12 | A4PlusPaper = 60, 13 | A4SmallPaper = 10, 14 | A4TransversePaper = 0x37, 15 | A5ExtraPaper = 0x40, 16 | A5Paper = 11, 17 | A5TransversePaper = 0x3d, 18 | B4Envelope = 0x21, 19 | B4Paper = 12, 20 | B5Envelope = 0x22, 21 | B5Paper = 13, 22 | B6Envelope = 0x23, 23 | C3Envelope = 0x1d, 24 | C4Envelope = 30, 25 | C5Envelope = 0x1c, 26 | C65Envelope = 0x20, 27 | C6Envelope = 0x1f, 28 | CPaper = 0x18, 29 | DlEnvelope = 0x1b, 30 | DPaper = 0x19, 31 | EPaper = 0x1a, 32 | ExecutivePaper = 7, 33 | FolioPaper = 14, 34 | GermanLegalFanfold = 0x29, 35 | GermanStandardFanfold = 40, 36 | InviteEnvelope = 0x2f, 37 | IsoB4 = 0x2a, 38 | IsoB5ExtraPaper = 0x41, 39 | ItalyEnvelope = 0x24, 40 | JapaneseDoublePostcard = 0x2b, 41 | JisB5TransversePaper = 0x3e, 42 | LedgerPaper = 4, 43 | LegalExtraPaper = 0x33, 44 | LegalPaper = 5, 45 | LetterExtraPaper = 50, 46 | LetterExtraTransversePaper = 0x38, 47 | LetterPaper = 1, 48 | LetterPlusPaper = 0x3b, 49 | LetterSmallPaper = 2, 50 | LetterTransversePaper = 0x36, 51 | MonarchEnvelope = 0x25, 52 | No10Envelope = 20, 53 | No11Envelope = 0x15, 54 | No12Envelope = 0x16, 55 | No14Envelope = 0x17, 56 | No634Envelope = 0x26, 57 | No9Envelope = 0x13, 58 | NotePaper = 0x12, 59 | QuartoPaper = 15, 60 | StandardPaper = 0x10, 61 | StandardPaper1 = 0x11, 62 | StandardPaper2 = 0x2c, 63 | StandardPaper3 = 0x2d, 64 | StandardPaper4 = 0x2e, 65 | StatementPaper = 6, 66 | SuperaSuperaA4Paper = 0x39, 67 | SuperbSuperbA3Paper = 0x3a, 68 | TabloidExtraPaper = 0x34, 69 | TabloidPaper = 3, 70 | UsStandardFanfold = 0x27 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/DoddleReport.OpenXml/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DoddleReport.OpenXml")] 9 | [assembly: AssemblyDescription("Adds OpenXML support to DoddleReport. The currently supported format is Excel and is more robust than the default ExcelReportWriter in DoddleReport.")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Matt Hidinger")] 12 | [assembly: AssemblyProduct("DoddleReport.OpenXml")] 13 | [assembly: AssemblyCopyright("Copyright © 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c01a6fb8-3791-4875-a948-5f23e00d3b13")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.5.2.0")] 36 | -------------------------------------------------------------------------------- /src/DoddleReport.OpenXml/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/DoddleReport.OpenXml/web.config.transform: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Areas/Reporting/Controllers/DoddleController.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | using DoddleReport.Sample.Web.Models; 3 | using DoddleReport.Web; 4 | 5 | namespace DoddleReport.Sample.Web.Areas.Reporting.Controllers 6 | { 7 | // Used for testing DoddleReport in an MVC Area 8 | 9 | public class DoddleAreaController : Controller 10 | { 11 | public ReportResult ProductReport() 12 | { 13 | var query = DoddleProductRepository.GetAll(); 14 | var report = new Report(query.ToReportSource()); 15 | return new ReportResult(report); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Areas/Reporting/ReportingAreaRegistration.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | using DoddleReport.Web; 3 | 4 | namespace DoddleReport.Sample.Web.Areas.Reporting 5 | { 6 | public class ReportingAreaRegistration : AreaRegistration 7 | { 8 | public override string AreaName 9 | { 10 | get 11 | { 12 | return "Reporting"; 13 | } 14 | } 15 | 16 | public override void RegisterArea(AreaRegistrationContext context) 17 | { 18 | context.MapReportingRoute(); 19 | 20 | 21 | context.MapRoute( 22 | "Reporting_default", 23 | "Reporting/{controller}/{action}/{id}", 24 | new { action = "Index", id = UrlParameter.Optional } 25 | ); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Areas/Reporting/Views/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Content/doddleHtmlReport.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthidinger/DoddleReport/d68c344d1b012937c7ff5b9c6e9233d421d1995e/src/DoddleReport.Sample.Web/Content/doddleHtmlReport.png -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Content/doddleTxtReport.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthidinger/DoddleReport/d68c344d1b012937c7ff5b9c6e9233d421d1995e/src/DoddleReport.Sample.Web/Content/doddleTxtReport.png -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Content/doddlepdfreport.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthidinger/DoddleReport/d68c344d1b012937c7ff5b9c6e9233d421d1995e/src/DoddleReport.Sample.Web/Content/doddlepdfreport.png -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Content/doddlexlsreport.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthidinger/DoddleReport/d68c344d1b012937c7ff5b9c6e9233d421d1995e/src/DoddleReport.Sample.Web/Content/doddlexlsreport.png -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Controllers/AbcPdfController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.Mvc; 3 | using DoddleReport.AbcPdf; 4 | using DoddleReport.Sample.Web.Helpers; 5 | using DoddleReport.Web; 6 | 7 | namespace DoddleReport.Sample.Web.Controllers 8 | { 9 | public class AbcPdfController : Controller 10 | { 11 | public ReportResult ProductReport() 12 | { 13 | var report = ProductReportHelper.GetProductReport(); 14 | 15 | report.DataFields["LastPurchase"].FormatAs(purchaseDate => purchaseDate.ToShortTimeString()); 16 | 17 | return new ReportResult(report, new PdfReportWriter()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Controllers/DataAnnotationsController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel.DataAnnotations; 3 | using System.Web.Mvc; 4 | using DoddleReport.Web; 5 | 6 | namespace DoddleReport.Sample.Web.Controllers 7 | { 8 | public class DataAnnotationsController : Controller 9 | { 10 | public class AnnotatedProduct 11 | { 12 | [Display(Name = "Product Name")] 13 | public string Name { get; set; } 14 | 15 | public decimal Price { get; set; } 16 | 17 | public bool OutOfStock { get; set; } 18 | } 19 | 20 | public ReportResult Index() 21 | { 22 | var list = new List(); 23 | 24 | 25 | list.Add(new AnnotatedProduct { Name = "Product 1", Price = 500 }); 26 | list.Add(new AnnotatedProduct { Name = "Product 2", Price = 600 }); 27 | list.Add(new AnnotatedProduct { Name = "Product 3", Price = 700 }); 28 | 29 | var report = new Report(list.ToReportSource()); 30 | 31 | 32 | // Adavanced data field formatting using a callback delegate 33 | report.DataFields["OutOfStock"].FormatAs(value => value ? "Yes" : "No"); 34 | 35 | return new ReportResult(report); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Controllers/DoddleController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Web.Mvc; 4 | using System.Dynamic; 5 | using System.Collections.Generic; 6 | using System.Drawing; 7 | using DoddleReport.Sample.Web.Models; 8 | using DoddleReport; 9 | using DoddleReport.Web; 10 | 11 | namespace DoddleReport.Sample.Web.Controllers 12 | { 13 | // ********************** 14 | // 15 | // Don't forget to edit your RouteConfig and call the following method at the top of RegisterRoutes() 16 | // 17 | // routes.MapReportingRoute(); 18 | // 19 | // See https://github.com/matthidinger/DoddleReport/wiki/ASP.NET-Reporting for details 20 | // ********************** 21 | 22 | 23 | public class DoddleController : Controller 24 | { 25 | // 26 | // Try the following sample URLs: 27 | // 28 | // http://localhost:X/doddle/ProductReport.html 29 | // http://localhost:X/doddle/ProductReport.txt 30 | // http://localhost:X/doddle/ProductReport.xls 31 | // http://localhost:X/doddle/ProductReport.xlsx (Requires DoddleReport.OpenXml) 32 | // http://localhost:X/doddle/ProductReport.pdf (Requires DoddleReport.iTextSharp or DoddleReport.AbcPdf) 33 | // 34 | 35 | public ReportResult ProductReport() 36 | { 37 | // Get the data for the report (any IEnumerable will work) 38 | var query = DoddleProductRepository.GetAll(); 39 | var totalProducts = query.Count; 40 | var totalOrders = query.Sum(p => p.OrderCount); 41 | 42 | // Create the report and turn our query into a ReportSource 43 | var report = new Report(query.ToReportSource()); 44 | 45 | 46 | // Customize the Text Fields 47 | report.TextFields.Title = "Products Report"; 48 | report.TextFields.SubTitle = "This is a sample report showing how Doddle Report works"; 49 | report.TextFields.Footer = "Copyright 2011 (c) The Doddle Project"; 50 | report.TextFields.Header = string.Format(@" 51 | Report Generated: {0} 52 | Total Products: {1} 53 | Total Orders: {2} 54 | Total Sales: {3:c}", DateTime.Now, totalProducts, totalOrders, totalProducts * totalOrders); 55 | 56 | 57 | // Render hints allow you to pass additional hints to the reports as they are being rendered 58 | report.RenderHints.BooleanCheckboxes = true; 59 | report.RenderHints.BooleansAsYesNo = true; 60 | report.RenderHints.FreezeRows = 9; 61 | report.RenderHints.FreezeColumns = 2; 62 | 63 | // Some writers (like PDF) support Orientation and page sizing 64 | //report.RenderHints.Orientation = ReportOrientation.Landscape; 65 | //report.RenderHints.PageSize = new SizeF(8.5f * 72f, 14f * 72f); //US Legal paper size 66 | //report.RenderHints.PageSize = new SizeF(595.28f, 841.89f); //A4 paper size 67 | //report.RenderHints.PageSize = new SizeF(842f, 1191f); //A3 paper size 68 | 69 | 70 | // Customize the data fields 71 | report.DataFields["Id"].Hidden = true; 72 | report.DataFields["Price"].DataFormatString = "{0:c}"; 73 | report.DataFields["Price"].ShowTotals = true; 74 | report.DataFields["LastPurchase"].DataFormatString = "{0:d}"; 75 | 76 | // Assign a delegate to generate a string that will be used as the href attribute 77 | // for a link in the given field, specific to the dataitem for that row. 78 | // Some literal or constant is necessary for the root url if you want Excel 79 | // navigable links in any writer that doesn't render in the context of the 80 | // given web project (e.g. excel or pdf) 81 | // ReSharper disable Mvc.ActionNotResolved 82 | // ReSharper disable Mvc.ControllerNotResolved 83 | report.DataFields["Name"].Url(p => Url.Action("Index", "Products", new { p.Id }, "http")); 84 | // ReSharper restore Mvc.ControllerNotResolved 85 | // ReSharper restore Mvc.ActionNotResolved 86 | 87 | // Advanced customized on a row-by-row basis 88 | report.RenderingRow += report_RenderingRow; 89 | 90 | 91 | // Return the ReportResult 92 | // the type of report that is rendered will be determined by the extension in the URL (.pdf, .xls, .html, etc) 93 | return new ReportResult(report); 94 | } 95 | 96 | void report_RenderingRow(object sender, ReportRowEventArgs e) 97 | { 98 | switch (e.Row.RowType) 99 | { 100 | case ReportRowType.HeaderRow: 101 | e.Row.Fields["LastPurchase"].HeaderStyle.TextRotation = -90; 102 | e.Row.Fields["UnitsInStock"].HeaderStyle.TextRotation = -90; 103 | e.Row.Fields["LowStock"].HeaderStyle.TextRotation = -90; 104 | break; 105 | case ReportRowType.DataRow: 106 | { 107 | var unitsInStock = (int)e.Row["UnitsInStock"]; 108 | if (unitsInStock < 100) 109 | { 110 | e.Row.Fields["UnitsInStock"].DataStyle.Bold = true; 111 | e.Row.Fields["UnitsInStock"].DataStyle.ForeColor = Color.Maroon; 112 | } 113 | } 114 | break; 115 | } 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Controllers/DynamicController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Dynamic; 4 | using System.Web.Mvc; 5 | using DoddleReport.Sample.Web.Models; 6 | using DoddleReport.Web; 7 | 8 | namespace DoddleReport.Sample.Web.Controllers 9 | { 10 | public class DynamicController : Controller 11 | { 12 | // 13 | // Sample URLs: 14 | // http://localhost:X/Reporting/Dynamic/Dynamic.html 15 | // http://localhost:X/Reporting/Dynamic/Dynamic.xls 16 | // http://localhost:X/Reporting/Dynamic/Dynamic.txt 17 | // http://localhost:X/Reporting/Dynamic/Dynamic.pdf (REQUIRES ABCPDF INSTALLED) 18 | // 19 | 20 | public ReportResult Dynamic() 21 | { 22 | var all = new List(); 23 | dynamic d = new ExpandoObject(); 24 | d.DistrictNumber = 1566; 25 | d.SchoolId = 1; 26 | d.FullName = "Matt Hidinger"; 27 | 28 | dynamic d2 = new ExpandoObject(); 29 | d2.DistrictNumber = 13566; 30 | d2.SchoolId = 1; 31 | d2.FullName = "Bob Jones"; 32 | 33 | all.Add(d); 34 | all.Add(d2); 35 | 36 | var report = new Report(all.ToReportSource()); 37 | 38 | // Customize the Text Fields 39 | report.TextFields.Title = "Dynamic Report"; 40 | report.TextFields.SubTitle = "This is a sample report showing how Doddle Report works"; 41 | report.TextFields.Footer = "Copyright 2011-2012 (c) The Doddle Project"; 42 | report.TextFields.Header = string.Format(@"Report Generated: {0}", DateTime.Now); 43 | 44 | report.DataFields["SchoolId"].HeaderText = "School"; 45 | 46 | // Render hints allow you to pass additional hints to the reports as they are being rendered 47 | report.RenderHints.BooleanCheckboxes = true; 48 | 49 | return new ReportResult(report); 50 | } 51 | 52 | public ReportResult DynamicNulls() 53 | { 54 | var all = new List(); 55 | 56 | var product = new Product 57 | { 58 | Id = 1, 59 | Name = "Hammer", 60 | Description = "Unit Tester Widget", 61 | Price = 42, 62 | OrderCount = 10, 63 | UnitsInStock = 4 64 | }; 65 | 66 | dynamic item = new ExpandoObject(); 67 | item.Id = product.Id; 68 | item.Name = product.Name; 69 | item.Description = product.Description; 70 | item.Price = product.Price; 71 | item.OrderCount = product.OrderCount; 72 | item.LastPuchase = product.LastPurchase; 73 | item.UnitsInStock = product.UnitsInStock; 74 | item.LowStock = product.LowStock; 75 | 76 | all.Add(item); 77 | 78 | product = new Product 79 | { 80 | Id = 2, 81 | Name = "Secret", 82 | Price = 84.42, 83 | OrderCount = 1, 84 | UnitsInStock = 2 85 | }; 86 | 87 | item = new ExpandoObject(); 88 | item.Id = product.Id; 89 | item.Name = product.Name; 90 | item.Description = product.Description; 91 | item.Price = product.Price; 92 | item.OrderCount = product.OrderCount; 93 | item.LastPuchase = product.LastPurchase; 94 | item.UnitsInStock = product.UnitsInStock; 95 | item.LowStock = product.LowStock; 96 | 97 | all.Add(item); 98 | 99 | var report = new Report(all.ToReportSource()); 100 | 101 | // Customize the Text Fields 102 | report.TextFields.Title = "Dynamic Report with NULL values present"; 103 | report.TextFields.SubTitle = "This is a sample report showing how Doddle Report works"; 104 | report.TextFields.Footer = "Copyright 2011-2012 (c) The Doddle Project"; 105 | report.TextFields.Header = string.Format(@"Report Generated: {0}", DateTime.Now); 106 | 107 | report.DataFields["OrderCount"].HeaderText = "Order Count"; 108 | report.DataFields["UnitsInStock"].HeaderText = "Units in Stock"; 109 | report.DataFields["LowStock"].HeaderText = "Stock Low"; 110 | 111 | // Render hints allow you to pass additional hints to the reports as they are being rendered 112 | report.RenderHints.BooleanCheckboxes = true; 113 | 114 | return new ReportResult(report); 115 | } 116 | 117 | public ReportResult ProductReport() 118 | { 119 | IEnumerable query = DoddleProductRepository.GetAllExpando(); 120 | var report = new Report(query.ToReportSource()); 121 | return new ReportResult(report); 122 | } 123 | 124 | public ReportResult ProductReportObject() 125 | { 126 | IEnumerable query = DoddleProductRepository.GetAll(); 127 | var report = new Report(query.ToReportSource()); 128 | return new ReportResult(report); 129 | } 130 | 131 | public ReportResult ProductReportObjectExpando() 132 | { 133 | IEnumerable query = DoddleProductRepository.GetAllExpando(); 134 | var report = new Report(query.ToReportSource()); 135 | return new ReportResult(report); 136 | } 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Controllers/ExpandoController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Dynamic; 4 | using System.Web.Mvc; 5 | using DoddleReport.Sample.Web.Models; 6 | using DoddleReport.Web; 7 | 8 | namespace DoddleReport.Sample.Web.Controllers 9 | { 10 | public class ExpandoController : Controller 11 | { 12 | 13 | // 14 | // Sample URLs: 15 | // http://localhost:X/Home/Index/Reporting/Expando/Expando.html 16 | // http://localhost:X/Home/Index/Reporting/Expando/Expando.xls 17 | // http://localhost:X/Home/Index/Reporting/Expando/Expando.txt 18 | // http://localhost:X/Home/Index/Reporting/Expando/Expando.pdf (REQUIRES ABCPDF INSTALLED) 19 | // 20 | 21 | public ReportResult Expando() 22 | { 23 | var all = new List(); 24 | dynamic d = new ExpandoObject(); 25 | d.DistrictNumber = 1566; 26 | d.SchoolId = 1; 27 | d.FullName = "Matt Hidinger"; 28 | 29 | dynamic d2 = new ExpandoObject(); 30 | d2.DistrictNumber = 13566; 31 | d2.SchoolId = 1; 32 | d2.FullName = "Bob Jones"; 33 | 34 | 35 | all.Add(d); 36 | all.Add(d2); 37 | 38 | var report = new Report(all.ToReportSource()); 39 | 40 | // Customize the Text Fields 41 | report.TextFields.Title = "Expando Report"; 42 | report.TextFields.SubTitle = "This is a sample report showing how Doddle Report works"; 43 | report.TextFields.Footer = "Copyright 2011 (c) The Doddle Project"; 44 | report.TextFields.Header = string.Format(@"Report Generated: {0}", DateTime.Now); 45 | 46 | report.DataFields["SchoolId"].HeaderText = "School"; 47 | 48 | // Render hints allow you to pass additional hints to the reports as they are being rendered 49 | report.RenderHints.BooleanCheckboxes = true; 50 | 51 | return new ReportResult(report); 52 | } 53 | 54 | public ReportResult ProductReport() 55 | { 56 | var query = DoddleProductRepository.GetAllExpando(); 57 | var report = new Report(query.ToReportSource()); 58 | return new ReportResult(report); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | 3 | namespace DoddleReport.Sample.Web.Controllers 4 | { 5 | public class HomeController : Controller 6 | { 7 | public ActionResult Index() 8 | { 9 | return View(); 10 | } 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Controllers/TestController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Web.Mvc; 3 | using DoddleReport.Sample.Web.Models; 4 | using DoddleReport.Web; 5 | using DoddleReport.Writers; 6 | 7 | namespace DoddleReport.Sample.Web.Controllers 8 | { 9 | public class TestController : Controller 10 | { 11 | public ReportResult ListOfObjects() 12 | { 13 | var list = new List(); 14 | 15 | 16 | list.Add(new 17 | { 18 | FirstName = "Matt", 19 | LastName = "Hidinger" 20 | }); 21 | 22 | var report = new Report(list.ToReportSource()); 23 | return new ReportResult(report); 24 | } 25 | 26 | public ReportResult WithExtension() 27 | { 28 | var query = DoddleProductRepository.GetAll(); 29 | var report = new Report(query.ToReportSource()); 30 | return new ReportResult(report) { FileName = "CustomName.html"}; 31 | } 32 | 33 | public ReportResult CustomHtmlStyle() 34 | { 35 | var query = DoddleProductRepository.GetAll(); 36 | var report = new Report(query.ToReportSource()); 37 | 38 | //report.RenderHints["HtmlStyle"] = @".htmlReport th { font-size: 40px !important; }"; 39 | foreach (var dataField in report.DataFields) 40 | { 41 | dataField.HeaderStyle.FontSize = 13; 42 | } 43 | return new ReportResult(report); 44 | } 45 | 46 | public ReportResult WithExtensionAndWriter() 47 | { 48 | var query = DoddleProductRepository.GetAll(); 49 | var report = new Report(query.ToReportSource()); 50 | return new ReportResult(report, new DelimitedTextReportWriter()) { FileName = "CustomName.txt" }; 51 | } 52 | 53 | public ReportResult WithoutExtension() 54 | { 55 | var query = DoddleProductRepository.GetAll(); 56 | var report = new Report(query.ToReportSource()); 57 | return new ReportResult(report) { FileName = "CustomName" }; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/DoddleReport.Sample.Mvc.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DoddleReport.Sample.Mvc 5 | 1.5.2 6 | DoddleReport.Sample.Mvc 7 | Matt Hidinger 8 | Matt Hidinger 9 | https://github.com/matthidinger/DoddleReport 10 | false 11 | Sample usage of DoddleReport in an MVC application 12 | doddle.report doddle.reporting doddle reporting pdf excel csv 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="DoddleReport.Sample.Web.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Configuration; 3 | using System.Diagnostics; 4 | using System.Web.Mvc; 5 | using System.Web.Routing; 6 | using DoddleReport.Web; 7 | 8 | namespace DoddleReport.Sample.Web 9 | { 10 | public class MvcApplication : System.Web.HttpApplication 11 | { 12 | public static void RegisterRoutes(RouteCollection routes) 13 | { 14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 15 | 16 | //DelimitedTextReportWriter.GetHeaderText = field => field.HeaderText; 17 | 18 | 19 | routes.MapRoute("LegacyUrl", 20 | "home/{action}.{extension}", 21 | new { controller = "Doddle" }, 22 | new { extension = new ReportRouteConstraint() } 23 | ); 24 | 25 | routes.MapReportingRoute(); 26 | 27 | routes.MapRoute( 28 | "Default", // Route name 29 | "{controller}/{action}/{id}", // URL with parameters 30 | new { controller = "Home", action = "Index", id = UrlParameter.Optional, area = "" } // Parameter defaults 31 | ); 32 | } 33 | 34 | protected void Application_Start() 35 | { 36 | TryRegisterAbcPdf(); 37 | 38 | AreaRegistration.RegisterAllAreas(); 39 | 40 | RegisterRoutes(RouteTable.Routes); 41 | } 42 | 43 | private static void TryRegisterAbcPdf() 44 | { 45 | try 46 | { 47 | var abcPdfLicenseKey = ConfigurationManager.AppSettings["AbcPdfLicense"]; 48 | 49 | if (!string.IsNullOrWhiteSpace(abcPdfLicenseKey)) 50 | { 51 | var success = WebSupergoo.ABCpdf7.XSettings.InstallRedistributionLicense(abcPdfLicenseKey); 52 | Debug.WriteLine("ABC PDF Registered: {0}", success); 53 | } 54 | } 55 | catch 56 | { 57 | } 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Helpers/ProductReportHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using DoddleReport.Sample.Web.Models; 4 | 5 | namespace DoddleReport.Sample.Web.Helpers 6 | { 7 | public static class ProductReportHelper 8 | { 9 | public static Report GetProductReport() 10 | { 11 | // Get the data for the report (any IEnumerable will work) 12 | var query = DoddleProductRepository.GetAll(); 13 | var totalProducts = query.Count; 14 | var totalOrders = query.Sum(p => p.OrderCount); 15 | 16 | 17 | // Create the report and turn our query into a ReportSource 18 | var report = new Report(query.ToReportSource()); 19 | 20 | 21 | // Customize the Text Fields 22 | report.TextFields.Title = "Products Report"; 23 | report.TextFields.SubTitle = "This is a sample report showing how Doddle Report works"; 24 | report.TextFields.Footer = "Copyright 2011 (c) The Doddle Project"; 25 | report.TextFields.Header = string.Format(@" 26 | Report Generated: {0} 27 | Total Products: {1} 28 | Total Orders: {2} 29 | Total Sales: {3:c}", DateTime.Now, totalProducts, totalOrders, totalProducts * totalOrders); 30 | 31 | 32 | // Render hints allow you to pass additional hints to the reports as they are being rendered 33 | report.RenderHints.BooleanCheckboxes = true; 34 | report.RenderHints.BooleansAsYesNo = true; 35 | //report.RenderHints.Orientation = ReportOrientation.Landscape; 36 | 37 | 38 | // Customize the data fields 39 | report.DataFields["Id"].Hidden = true; 40 | report.DataFields["Price"].DataFormatString = "{0:c}"; 41 | report.DataFields["Price"].ShowTotals = true; 42 | report.DataFields["LastPurchase"].DataFormatString = "{0:d}"; 43 | 44 | return report; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Models/DoddleProductRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Dynamic; 4 | using System.Linq; 5 | 6 | namespace DoddleReport.Sample.Web.Models 7 | { 8 | public class Product 9 | { 10 | public int Id { get; set; } 11 | public string Name { get; set; } 12 | public string Description { get; set; } 13 | public double Price { get; set; } 14 | public int OrderCount { get; set; } 15 | public DateTime? LastPurchase { get; set; } 16 | public int UnitsInStock { get; set; } 17 | public bool? LowStock 18 | { 19 | get { return UnitsInStock < 300; } 20 | } 21 | } 22 | 23 | public static class DoddleProductRepository 24 | { 25 | public static List GetAll() 26 | { 27 | var rand = new Random(); 28 | return Enumerable.Range(1, 200) 29 | .Select(i => new Product 30 | { 31 | Id = i, 32 | Name = "Product" + i, 33 | Description = 34 | "This is an example description showing long text in some of the items. Here is some UTF text €", 35 | Price = rand.NextDouble()*100, 36 | OrderCount = rand.Next(1000), 37 | LastPurchase = DateTime.Now.AddDays(rand.Next(1000)), 38 | UnitsInStock = rand.Next(0, 1000) 39 | }) 40 | .ToList(); 41 | } 42 | 43 | public static IEnumerable GetAllExpando() 44 | { 45 | foreach(var product in GetAll()) 46 | { 47 | dynamic item = new ExpandoObject(); 48 | 49 | item.Id = product.Id; 50 | item.Name = product.Name; 51 | item.Description = product.Description + " (dynamic)"; 52 | item.Price = product.Price; 53 | item.OrderCount = product.OrderCount; 54 | item.LastPuchase = product.LastPurchase; 55 | item.UnitsInStock = product.UnitsInStock; 56 | item.LowStock = product.LowStock; 57 | 58 | yield return item; 59 | } 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DoddleReport.Sample.Web")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("DoddleReport.Sample.Web")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("3f6d9880-03e9-4053-9818-dc2880dadf62")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Views/Home/Index.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | Home Page 5 | 6 | 7 | 8 |

DoddleReport - turn any IEnumerable set of data into pluggable reports!

9 | 10 |

Find it on CodePlex

11 | 12 |

Usage

13 |
 14 | public ReportResult ProductReport()
 15 | {
 16 |     // Get the data for the report (any IEnumerable will work)
 17 |     var query = ProductRepository.GetAll();
 18 |     var totalProducts = query.Count;
 19 |     var totalOrders = query.Sum(p => p.OrderCount);
 20 | 
 21 | 
 22 |     // Create the report and turn our query into a ReportSource
 23 |     var report = new Report(query.ToReportSource());
 24 | 
 25 | 
 26 |     // Customize the Text Fields
 27 |     report.TextFields.Title = "Products Report";
 28 |     report.TextFields.SubTitle = "This is a sample report showing how Doddle Report works";
 29 |     report.TextFields.Footer = "Copyright 2011 &copy; The Doddle Project";
 30 |     report.TextFields.Header = string.Format(@"
 31 |         Report Generated: {0}
 32 |         Total Products: {1}
 33 |         Total Orders: {2}
 34 |         Total Sales: {3:c}", DateTime.Now, totalProducts, totalOrders, totalProducts * totalOrders);
 35 | 
 36 | 
 37 |     // Render hints allow you to pass additional hints to the reports as they are being rendered
 38 |     report.RenderHints.BooleanCheckboxes = true;
 39 | 
 40 | 
 41 |     // Customize the data fields
 42 |     report.DataFields["Id"].Hidden = true;
 43 |     report.DataFields["Price"].DataFormatString = "{0:c}";
 44 |     report.DataFields["LastPurchase"].DataFormatString = "{0:d}";
 45 | 
 46 | 
 47 | 
 48 |     // Return the ReportResult
 49 |     // the type of report that is rendered will be determined by the extension in the URL (.pdf, .xls, .html, etc)
 50 |     return new ReportResult(report);
 51 | }
 52 | 
53 | 54 |

Samples!

55 | 56 | 57 | 58 | 63 | 64 | 68 | 69 | 70 | 75 | 76 | 81 | 82 | 83 | 87 | 91 | 92 | 93 | 98 | 99 | 104 | 105 |
59 |

Excel Report - using OpenXML

60 | <%: Html.ActionLink("See it Live!", "ProductReport", "Doddle", new { extension = "xlsx"}, null) %> 61 | 62 |
65 |

PDF Report - using iTextSharp - headers repeat on every page

66 | <%: Html.ActionLink("See Live!", "ProductReport", "Doddle", new { extension = "pdf" }, null)%> 67 |
71 | "> 72 | " width="500" alt="Excel Report" /> 73 | 74 | 77 | "> 78 | " width="500" alt="PDF Report" /> 79 | 80 |
84 |

HTML Report

85 | <%: Html.ActionLink("See Live!", "ProductReport", "Doddle", new { extension = "html" }, null)%> 86 |
88 |

CSV/Delimited Output

89 | <%: Html.ActionLink("See Live!", "ProductReport", "Doddle", new { extension = "txt" }, null)%> 90 |
94 | "> 95 | " width="500" alt="HTML Report" /> 96 | 97 | 100 | "> 101 | " width="500" alt="CSV Report" /> 102 | 103 |
106 | 107 |
108 | -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Views/Shared/Error.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | Error 5 | 6 | 7 | 8 |

9 | Sorry, an error occurred while processing your request. 10 |

11 |
12 | -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Views/Shared/Site.Master: -------------------------------------------------------------------------------- 1 | <%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %> 2 | 3 | 4 | 5 | 6 | <asp:ContentPlaceHolder ID="TitleContent" runat="server" /> 7 | 8 | 9 | 10 | 11 |
12 | 13 | 30 | 31 |
32 | 33 | 34 | 36 |
37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Views/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /src/DoddleReport.Sample.Web/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | \n"); 54 | 55 | sb.Append("\n"); 114 | 115 | sb.Append("\n"); 116 | 117 | 118 | return sb.ToString(); 119 | 120 | } 121 | } 122 | } -------------------------------------------------------------------------------- /src/DoddleReport/web.config.transform: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 |