Reputation: 229
I have a Visual Studio solution that contains two projects (1) a C# console application; and (2) a C# Excel Workbook.
The console application creates some data, which I would then like to pass into the workbook.
To do this I have created a method in the Excel workbook project, which receives data from the console application. However, I cannot create an instance of the Excel book. At the moment I am trying:
Excel.Application excelApplication = new Excel.Application(); Excel.Workbook excelWorkBook = excelApplication.Workbooks.Add("MyBook.xls");
I could hard code the path to the xls file, but I don't really want to do this as I would prefer to wrap everything up into a single .exe
Any ideas?
Upvotes: 0
Views: 1076
Reputation: 117
So basically what you're asking is how to wrap two files (an exe and an excel file), into a single exe.
There is a simple (and fairly clumsy) way of doing this which revolves around using Resources
in C#, meaning your program will have to do something similar to the following:
Resources
, and write it to a file when the program is run (temporary file)Worksheet.Add
methodResources
of your exe.Another possibility would be, instead of using a temporary file, read a stream of bytes directly into Worksheets.Add
if this is supported by the API (feel free to tell me if this is so).
EDIT: Great tutorial on using resources in C#.
Upvotes: 1