Column Chart in Spreadsheet Document
In this article, we will use GroupDocs.Assembly to generate a Column Chart Report with Filtered, Ordered and Grouped Data in Spreadsheet Document format based on the use case: Working with a Business Case.
The code uses some of the objects defined in The Business Layer.
Column Chart in Microsoft Excel Document
Creating a Column Chart
Following below steps, you can create a column chart in MS Excel 2013:
- Create a new Workbook.
- Click the “Insert” tab, and then click “Insert Column Chart” icon in the Charts group to view the drop-down list.
- Select the “100% Stacked Column” and press “OK” to insert the chart and Worksheet template to your Worksheet.
- Edit the Worksheet with your data to update the chart. See Chart Data.
- Save your Document.
Reporting Requirement
As a report developer, you are required to share orders quantity of the customers dynamically with the following key requirements:
- A report must show the quantity of sales/orders.
- Sales/orders quantity must represented by Quarters.
- It must associate order quantity with the corresponding customer.
- A report must be generated in the Spreadsheet Document.
Adding Syntax to be evaluated by GroupDocs.Assembly Engine
Chart Title
Total Order Quantity by Quarters<<foreach [in orders
.Where(c => c.OrderDate.Year == 2015)
.GroupBy(c => c.Customer)
.OrderBy(g => g.Key.CustomerName)]>><<x [Key.CustomerName]>>
Chart Data
Legend Entries
="1st Quarter<<y [Where(c => c.OrderDate.Month >= 1 && c.OrderDate.Month <= 3).Sum(c => c.ProductQuantity)]>>"
="2nd Quarter<<y [Where(c => c.OrderDate.Month >= 4 && c.OrderDate.Month <= 6).Sum(c => c.ProductQuantity)]>>"
="3rd Quarter<<y [Where(c => c.OrderDate.Month >= 7 && c.OrderDate.Month <= 9).Sum(c => c.ProductQuantity)]>>"
="4th Quarter<<y [Where(c => c.OrderDate.Month >= 10 && c.OrderDate.Month <= 12).Sum(c => c.ProductQuantity)]>>"
For detailed technical information about syntax, expressions and report generation by the engine, please visit: Working with GroupDocs.Assembly Engine.
Download Template
Please download the sample Chart with Filtering, Grouping, and Ordering document we created in this article:
- Chart Template.xlsx (Template for CustomObject and JSON examples)
- Chart Template_DB.xlsx (Template for DataSet, DataBase examples)
- Chart Template_XML.xlsx (Template for XML examples)
Generating The Report
Custom Objects
Database Entities
Using DataSet
Using XML DataSource
Using JSON DataSource
Column Chart in OpenOffice Spreadsheet Document
To be investigated.