Can I create PivotTable in excel by using Spreadsheet and keep it on memory stream ?

I want to create report excel to be pivot by using DocumentFormat.OpenXml.Spreadsheet and keep it on memory stream for send e-mail and I must upload to azure Webjob.

I know how to create with interop.excel and VBA macro but I must run on azure webjob.

please tell me how should I do, thank.