1

I have a VSTO add in I am looking to implement.

I would like to click a button and a list of products, names, etc would be placed onto the worksheet.

I understand that I could go through each individual item in the list and then write this cell by cell, but is there a way of literally just 'dumping' the data onto the worksheet?

Apologies if this is a really thick question.

Ricardo Deano
  • 2,769
  • 8
  • 47
  • 70

2 Answers2

0

Nope, there is no easy way to just 'dump' the data. You're going to have to do it the hard way. Just google for some examples, it's easy enough.

http://www.google.nl/search?q=c%23+export+data+to+excel

Edwin de Koning
  • 14,209
  • 7
  • 56
  • 74
0

That depends on where your "list of products, names, etc" are coming from. If those items are fixed, you can create a template document with a prepared worksheet containing these items. Put this document into an embedded resource of your program. When you want to create a new worksheet from this template, extract your resource to a temporary file and use the Excel API to copy the worksheet from your template to your working document.

Sounds perhaps more complicated than it is. Here

Read a file from a resource and write it to disk in C#

you find an example how to accomplish the "extract file from resource to temporary file" part.

Community
  • 1
  • 1
Doc Brown
  • 19,739
  • 7
  • 52
  • 88