Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to read pivot table data? #1315

Open
znakeeye opened this issue Dec 2, 2019 · 0 comments
Open

How to read pivot table data? #1315

znakeeye opened this issue Dec 2, 2019 · 0 comments

Comments

@znakeeye
Copy link

znakeeye commented Dec 2, 2019

foo.xlsx
How do you read the pivot table data? I've tried all kinds of combinations, but none give me the right subset of fields/rows.

class Program
{
    static void Main(string[] args)
    {
        var wb = new XLWorkbook(@"foo.xlsx");
        var ws = wb.Worksheet("X");

        foreach (var pt in ws.PivotTables)
        {
            var r = pt.SourceRange;
            foreach (var row in r.Rows())
            {
                var v = string.Join(", ", row.Cells().Select(c => c.CachedValue));
                Console.WriteLine(v);
            }
        }
    }
}

Expected output:

Foo
a
b
c
d

Actual output:

Id, Foo, Bar
1, a, a1
2, b, a2
3, c, a3
4, d, a4

Ideally, I want to filter out any labels too.

Version of ClosedXML
0.95 beta2

@ClosedXML ClosedXML deleted a comment from inansen Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant