Good news for your use case 1, we have already an extension that does it on our gallery here. And for inspiration for the Write Back André wrote a write back extension to a local file, you can find the code here.
I hope it is helpful,
Bryan is asking for 'Crosstab' not for raw data. None of this will be suitable for his case.
If you know about another solution please share