I wrote a program in WPF that has to write in an Excel file. The Excel File already exists (I created it so the file exists!), but I want that if I publish my program that users also have this Excel file automatically.
So how can I fill this gap with the "?" (There should be the Excel file)
At the moment, I only open the file:
if (Properties.Settings.Default.AlsExcel == true)
{
Excel.Application objExcel = new Excel.Application();
objExcel.Visible = false;
objExcel.WindowState = Excel.XlWindowState.xlNormal;
object missing = Missing.Value;
string Name = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DienstplanEx.xlsx");
Excel.Workbook objWorkbook = objExcel.Workbooks.Open(Name, missing, missing, missing,
missing, missing, missing, missing, missing, missing, missing, missing, missing,
missing, missing);
Excel.Worksheet worksheet = (Excel.Worksheet)objWorkbook.Worksheets["Tabelle1"];
if (!Directory.Exists(Pfad))
{
Directory.CreateDirectory(Pfad);
}
objWorkbook.SaveAs(Pfad + "\\Plan.xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
objWorkbook.Close();
objExcel.Quit();