Create new row in specific sheet of the excel document VS C#

  Uncategorised

I know that this problem may be addressed in another asked question, is not cause I lost 2 days trying them all.
Lets start the topic:
-I have an desktop app made in Visual Studio Express 2017, C# code used.
-I take 3 variables that I want to store in an excel document that has multiple sheets: Overtime nr. of hours, Day, comment.
Every sheet belongs to an individual that is based on pc username.

string datforOV = monthCalendar1.SelectionRange.Start.ToShortDateString();                              //data string
            double hours = decimal.ToDouble(numericUpDown1.Value) + decimal.ToDouble(numericUpDown2.Value) * 0.1;   //number of hours
            string box = richTextBox1.Text;                                                                         //content of text box

            Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
            Microsoft.Office.Interop.Excel.Worksheet xlsht = new Microsoft.Office.Interop.Excel.Worksheet();           
            string path = @"ZOLP.xlsx";
            xlsht = xlApp.Application.Workbooks.Open(path).Worksheets[Environment.UserName];

I need to add a new row, in the sheet named already after the Username, and fill the first column with nr of hours, second column with the day, and the next one with the comment.
Please help me cause I started losing my minds. Thank in advance.

Source: Visual Studio Questions

LEAVE A COMMENT