Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6603771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:03:36+00:00 2026-05-25T19:03:36+00:00

I’m using EPPlus to create Excel reports. Now i’m trying to create a Pivot

  • 0

I’m using EPPlus to create Excel reports.
Now i’m trying to create a Pivot with a DateTime PageField, so that the user can filter the period he want to see by himself. But although i can filter this for year,month or days in the according data worksheet by default, i don’t get it working in the Pivot.

Here is what i have:

Dim wsPivot = excel.Workbook.Worksheets.Add("Pivot")
Dim wsData = excel.Workbook.Worksheets.Add("Data")
Dim source = workSheet.GetDataSource
wsData.Cells("A1").LoadFromDataTable(source, True, OfficeOpenXml.Table.TableStyles.Medium6)
For Each col As DataColumn In source.Columns
    If col.DataType = GetType(Date) Then
        Dim colNumber = col.Ordinal + 1
        Dim range = wsData.Cells(1, colNumber, source.Rows.Count, colNumber)
        range.Style.Numberformat.Format = "dd.mm.yyyy"
   End If
Next
Dim dataRange = wsData.Cells(wsData.Dimension.Address.ToString())
dataRange.AutoFitColumns()
Dim pivotTable = wsPivot.PivotTables.Add(wsPivot.Cells("A3"), dataRange, "Open Contacts")
pivotTable.PageFields.Add(pivotTable.Fields("OwnedAt")) '** this is the date column i want to group **'
pivotTable.PageFields.Add(pivotTable.Fields("Owner"))
pivotTable.RowFields.Add(pivotTable.Fields("Country"))
pivotTable.ColumnFields.Add(pivotTable.Fields("Status"))
pivotTable.DataFields.Add(pivotTable.Fields("Count"))

It’s only possible to select datetime values from the list including hours and minutes and not to group by month f.e.(see picture below).

enter image description here

Here is the filter-list from the data-worksheet. How to get this in pivot?

enter image description here

Thank you in advance.

Note: I’ve also asked this on codeplex without success. Maybe someone else can help even if he has no experiences with EPPlus but knows similar issues with other libraries.
I could split the DateTime values into separate columns per sql(year,month,day). But i’m afraid that the pivot will get more confusing with so many fields( i also would have to split the other date fields).
Even with no experiences at all in programatically generating pivots, what would experienced excel users(i’m not) recommend?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:03:36+00:00Added an answer on May 25, 2026 at 7:03 pm

    The reason why excel could not group by my date-field neither in PageField nor in RowField was because there was one unformatted row in the data sheet. The following lines cause this issue(see complete code in my question):

    Dim range = wsData.Cells(1, colNumber, source.Rows.Count, colNumber)
    range.Style.Numberformat.Format = "dd.mm.yyyy"
    

    The parameters in the range’s Cells-Method are:

    1. From-Row 2. From-Column 3. To-Row 4. To-Column
    

    Because LoadFromDataTable loaded the DataTable with the Colums’ names as header, the last row kept unformatted, therefore the pivot cannot group the date.

    So this fixed it:

    Dim range = wsData.Cells(2, colNumber, source.Rows.Count + 1, colNumber)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.