title: Saving an excel template as part of the resources C# Visual Studio
body: <p>I am working on my first C# project which has the goal of reading out configuration files, saving the read data in an existing excel template and then saving a copy of the excel file at the desired location.</p>
  
  <p>The parsing part has been successfully created, I also know how to do this task with an actual existing excel template as long I know its location. But I'm trying to overcome the problem of having to keep the excel template as part of the directory, my goal would be to have the excel file as part of my final executable. </p>
  
  <p>I have read other questions similar to mine but I think I'm just not experienced enough to understand what I really have to do.</p>
  
  <h2><strong>What I have:</strong></h2>
  
  <pre><code>using Excel = Microsoft.Office.Interop.Excel;
  using Microsoft.Office.Core;
  Excel excel = new Excel(startupPath + @"\template_hm_mach10x.xlsx", 1);
  </code></pre>
  
  <p>This is how I create the excel instance that I will be working with, it is an existing template that I have placed in the /debug folder so I could work with it in my prototype.</p>
  
  <p>I then alter the template using </p>
  
  <pre><code> ws = wb.Worksheets[d.Ws];
   wb.Worksheets[d.Ws].Select();
   ws.Cells[d.Row, d.Col].Value2 = d.Data;
  </code></pre>
  
  <p>and then save the file using  <code>excel.SaveAs(saveFileDialog.FileName.ToString());
  </code></p>
  
  <h2><strong>What I have tried</strong></h2>
  
  <p>I have already tried to add the template to my solution by doing:</p>
  
  <p>Right-Click on my Solution > Add.. > Existing item> Select the item </p>
  
  <p>there I tried to look for the assembly options of the file but I couldn't find them in the properties :</p>
  
  <p><a href="https://i.stack.imgur.com/z11aA.png" rel="nofollow noreferrer">Screenshot of all the available File Properties</a></p>
  
  <p>I have also tried to add it to the Project and it gave me the option of "Copy to output", but I don't know how that would help me, or what it does.</p>
  
  <h2><strong>What I have researched</strong></h2>
  
  <p>I have read about people saving the template as a binary string of some sort and then generating the file and saving it on the Computer, that would be a good solution for me, but having never worked with this I just don't know how it should be realized. I think it would be the best solution since the enduser wouldn't have access to the template file anymore and it would just be very interesting for me to learn how to do that.</p>
  
  <p>But if that is no solution for my problem, then I'd be happy to learn how to make the template file part of the Programm and being able to use a relative path to it.</p>
  
  <p>Thank you all for your help !
  I have tried to ask this question before but it was my first question ever on this website and I think I just didn't do a good job asking my question precisely.</p>
  
  <p>If there is more information needed on any part of my code or IDE I will gladly Edit it in.</p>