-1

I am exporting a data table to Excel using EPPlus but I keep getting no results. I get a worksheet with headers and a label on the tab but no data. I verified that the tableadapter has data in it.

Here is my code:

        FileInfo newFile = new FileInfo("c:\temp\fn.xlsx");
        ExcelPackage epp = new ExcelPackage(newFile);
        var ws = epp.Workbook.Worksheets.Add(acctno);
        TransTableAdapter.FillByAcct(MSDataSet.TransWithName, acctno);
        ws.Cells.LoadFromDataTable(MSDataSet.TransWithName, true, OfficeOpenXml.Table.TableStyles.Light8);
        epp.Save();
        epp.Dispose();

Please kindly help if you can. Thanks!

Missy
  • 1,286
  • 23
  • 52
  • 1
    What is a `TransTableAdapter`? – mason Nov 08 '16 at 18:02
  • It's just the name for my transaction file table adapter. – Missy Nov 08 '16 at 22:29
  • It appears to be something you wrote. We don't have access to `TransTableAdapter.FillByAcct` or `TransTableAdapter.GetDataByDFI` so we have no idea what you're doing in those. Your question should include an [MCVE](http://stackoverflow.com/help/mcve) in the future. I realize you corrected your solution, but it really helps no one but you, and that is not the purpose of SO. – mason Nov 09 '16 at 14:36
  • Actually, it doesn't matter what the .FillBy or .GetDataBy does. The question is about using EPP. – Missy Nov 09 '16 at 18:31
  • If it doesn't matter what it does, why include it in the question? And it certainly did seem to matter, as changing that was integral to the solution you posted. – mason Nov 09 '16 at 18:33
  • The statement mattered but the actual contents of the FillBy and GetBy didn't matter. It's always some variation of select * from Filename. Seriously, this is helpful info as it took me hours and hours to figure out. Thanks for the down votes BTW. I mean, really, what the heck? – Missy Nov 09 '16 at 18:55
  • It does matter, because we do not have access to your code and have no idea what the functional call does unless you include it in your question. If someone else has a similar issue, they're not going to be able to change from `TransTableAdapter.FillByAcct` to `TransTableAdapter.GetDataByDFI` and they're not going to know what the difference is between them since you did not provide that code. It's great that you solved your problem, but this is a lot quality question because it did not include an [MCVE](http://stackoverflow.com/help/mcve) and the solution helps no one but you. – mason Nov 09 '16 at 18:59
  • Seriously, I'm not going to get in a bickering match with you. – Missy Nov 09 '16 at 18:59
  • 1
    That's fine. I'm not personally attacking you or trying to bicker, I'm trying to teach you something important about this site. I've been around quite a while, and learning what information is important to provide is an essential skill, as is taking constructive criticism. – mason Nov 09 '16 at 19:02

1 Answers1

-1

In case anyone else runs into this problem, here is the solution -- use GET and not FILL:

 MSDataSet.TransDataTable newTransTable;
 newTransTable = TransTableAdapter.GetDataByDFI(@acctno);
 ws.Cells.LoadFromDataTable(newTransTable, true, OfficeOpenXml.Table.TableStyles.Light8);
Missy
  • 1,286
  • 23
  • 52