0

I need to get data from the database and send it to the FTP server in XLS format. I have done the same for XML using memory stream. But, I am not sure how to format and load XLS to memory stream. Any idea or approach? Sample code always helps.

Learner
  • 3,904
  • 6
  • 29
  • 44

2 Answers2

0

I misunderstood your question. Read file to stream is standard for all files.

 new MemoryStream(File.ReadAllBytes(inputFilename))
Osa E
  • 1,711
  • 1
  • 15
  • 26
  • It's good for saving XLS locally, but I still don't get how to load the XLS formatted data to memory stream directly. Any idea? – Learner Feb 22 '13 at 19:38
  • Look at the code link above (http://code.google.com/p/excellibrary/source/browse/trunk/src/ExcelLibrary/Office/Excel/SpreadSheet/Workbook.cs). I do see "public void Save(Stream stream)" – Osa E Feb 22 '13 at 19:40
  • Yes, but that means it's expecting stream as a parameter and not that it converts it to stream. – Learner Feb 22 '13 at 19:42
0

Please see this answer, which uses the Excel OpenXML format. The fastest way to get an Excel without any external library.

Export DataTable to Excel with Open Xml SDK in c#

Community
  • 1
  • 1
Vincent
  • 22,366
  • 18
  • 58
  • 61
  • It's good for saving XLS locally, but I still don't get how to load the XLS formatted data to memory stream. Any idea? – Learner Feb 22 '13 at 19:38